Class SpscUnboundedAtomicArrayQueue<T>

java.lang.Object
rx.internal.util.atomic.SpscUnboundedAtomicArrayQueue<T>
Type Parameters:
T - the value type held by this queue
All Implemented Interfaces:
Iterable<T>, Collection<T>, Queue<T>

public final class SpscUnboundedAtomicArrayQueue<T> extends Object implements Queue<T>
A single-producer single-consumer queue with unbounded capacity.

The implementation uses fixed, power-of-2 arrays to store elements and turns into a linked-list like structure if the production overshoots the consumption.

Note that the minimum capacity of the 'islands' are 8 due to how the look-ahead optimization works.

The implementation uses field updaters and thus should be platform-safe.

  • Field Details

    • MAX_LOOK_AHEAD_STEP

      static final int MAX_LOOK_AHEAD_STEP
    • producerIndex

      final AtomicLong producerIndex
    • producerLookAheadStep

      int producerLookAheadStep
    • producerLookAhead

      long producerLookAhead
    • producerMask

      int producerMask
    • producerBuffer

      AtomicReferenceArray<Object> producerBuffer
    • consumerMask

      int consumerMask
    • consumerBuffer

      AtomicReferenceArray<Object> consumerBuffer
    • consumerIndex

      final AtomicLong consumerIndex
    • HAS_NEXT

      private static final Object HAS_NEXT
  • Constructor Details

    • SpscUnboundedAtomicArrayQueue

      public SpscUnboundedAtomicArrayQueue(int bufferSize)
  • Method Details