Package rx.internal.util.unsafe
Class SpscUnboundedArrayQueue<E>
java.lang.Object
java.util.AbstractCollection<E>
java.util.AbstractQueue<E>
rx.internal.util.unsafe.SpscUnboundedArrayQueueProducerFields<E>
rx.internal.util.unsafe.SpscUnboundedArrayQueueProducerColdFields<E>
rx.internal.util.unsafe.SpscUnboundedArrayQueueL2Pad<E>
rx.internal.util.unsafe.SpscUnboundedArrayQueueConsumerColdField<E>
rx.internal.util.unsafe.SpscUnboundedArrayQueueConsumerField<E>
rx.internal.util.unsafe.SpscUnboundedArrayQueue<E>
- All Implemented Interfaces:
Iterable<E>,Collection<E>,Queue<E>,QueueProgressIndicators
@SuppressAnimalSniffer
public class SpscUnboundedArrayQueue<E>
extends SpscUnboundedArrayQueueConsumerField<E>
implements QueueProgressIndicators
-
Field Summary
FieldsModifier and TypeFieldDescriptionprivate static final longprivate static final Object(package private) static final intprivate static final longprivate static final longprivate static final intFields inherited from class rx.internal.util.unsafe.SpscUnboundedArrayQueueConsumerField
consumerIndexFields inherited from class rx.internal.util.unsafe.SpscUnboundedArrayQueueConsumerColdField
consumerBuffer, consumerMaskFields inherited from class rx.internal.util.unsafe.SpscUnboundedArrayQueueL2Pad
p0, p1, p10, p11, p12, p2, p3, p4, p5, p6, p7, p8, p9Fields inherited from class rx.internal.util.unsafe.SpscUnboundedArrayQueueProducerColdFields
producerBuffer, producerLookAhead, producerLookAheadStep, producerMaskFields inherited from class rx.internal.util.unsafe.SpscUnboundedArrayQueueProducerFields
producerIndex -
Constructor Summary
Constructors -
Method Summary
Modifier and TypeMethodDescriptionprivate voidadjustLookAheadStep(int capacity) private static longcalcDirectOffset(long index) private static longcalcWrappedOffset(long index, long mask) longThis method has no concurrent visibility semantics.longThis method has no concurrent visibility semantics.iterator()private longprivate static <E> ObjectlvElement(E[] buffer, long offset) private E[]private longprivate EnewBufferPeek(E[] nextBuffer, long index, long mask) private EnewBufferPoll(E[] nextBuffer, long index, long mask) final booleanfinal Epeek()final Epoll()private voidfinal intsize()private voidsoConsumerIndex(long v) private static voidprivate voidprivate voidsoProducerIndex(long v) private booleanwriteToQueue(E[] buffer, E e, long index, long offset) Methods inherited from class java.util.AbstractCollection
contains, containsAll, isEmpty, remove, removeAll, retainAll, toArray, toArray, toStringMethods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, wait, wait, waitMethods inherited from interface java.util.Collection
contains, containsAll, equals, hashCode, isEmpty, parallelStream, remove, removeAll, removeIf, retainAll, spliterator, stream, toArray, toArray, toArray
-
Field Details
-
MAX_LOOK_AHEAD_STEP
static final int MAX_LOOK_AHEAD_STEP -
P_INDEX_OFFSET
private static final long P_INDEX_OFFSET -
C_INDEX_OFFSET
private static final long C_INDEX_OFFSET -
REF_ARRAY_BASE
private static final long REF_ARRAY_BASE -
REF_ELEMENT_SHIFT
private static final int REF_ELEMENT_SHIFT -
HAS_NEXT
-
-
Constructor Details
-
SpscUnboundedArrayQueue
public SpscUnboundedArrayQueue(int bufferSize)
-
-
Method Details
-
iterator
- Specified by:
iteratorin interfaceCollection<E>- Specified by:
iteratorin interfaceIterable<E>- Specified by:
iteratorin classAbstractCollection<E>
-
offer
This implementation is correct for single producer thread use only.
-
writeToQueue
-
resize
-
soNext
-
lvNext
-
poll
This implementation is correct for single consumer thread use only.
-
newBufferPoll
-
peek
This implementation is correct for single consumer thread use only.
-
newBufferPeek
-
size
public final int size()- Specified by:
sizein interfaceCollection<E>- Specified by:
sizein classAbstractCollection<E>
-
adjustLookAheadStep
private void adjustLookAheadStep(int capacity) -
lvProducerIndex
private long lvProducerIndex() -
lvConsumerIndex
private long lvConsumerIndex() -
soProducerIndex
private void soProducerIndex(long v) -
soConsumerIndex
private void soConsumerIndex(long v) -
calcWrappedOffset
private static long calcWrappedOffset(long index, long mask) -
calcDirectOffset
private static long calcDirectOffset(long index) -
soElement
-
lvElement
-
currentProducerIndex
public long currentProducerIndex()Description copied from interface:QueueProgressIndicatorsThis method has no concurrent visibility semantics. The value returned may be negative. Under normal circumstances 2 consecutive calls to this method can offer an idea of progress made by producer threads by subtracting the 2 results though in extreme cases (if producers have progressed by more than 2^64) this may also fail.
This value will normally indicate number of elements passed into the queue, but may under some circumstances be a derivative of that figure. This method should not be used to derive size or emptiness.- Specified by:
currentProducerIndexin interfaceQueueProgressIndicators- Returns:
- the current value of the producer progress index
-
currentConsumerIndex
public long currentConsumerIndex()Description copied from interface:QueueProgressIndicatorsThis method has no concurrent visibility semantics. The value returned may be negative. Under normal circumstances 2 consecutive calls to this method can offer an idea of progress made by consumer threads by subtracting the 2 results though in extreme cases (if consumers have progressed by more than 2^64) this may also fail.
This value will normally indicate number of elements taken out of the queue, but may under some circumstances be a derivative of that figure. This method should not be used to derive size or emptiness.- Specified by:
currentConsumerIndexin interfaceQueueProgressIndicators- Returns:
- the current value of the consumer progress index
-