Class RingBuffer<E>

java.lang.Object
com.quantfinlib.marketdata.RingBuffer<E>

public final class RingBuffer<E> extends Object
Bounded lock-free single-producer / single-consumer ring buffer for ultra-low-latency event passing: no locks, no allocation on the hot path, power-of-two indexing.
  • Constructor Details

    • RingBuffer

      public RingBuffer(int capacity)
      Parameters:
      capacity - rounded up to the next power of two
  • Method Details

    • offer

      public boolean offer(E e)
      Producer side. Returns false if the buffer is full (caller decides drop/retry policy).
    • poll

      public E poll()
      Consumer side. Returns null when empty.
    • isEmpty

      public boolean isEmpty()
    • capacity

      public int capacity()