public class MpmcAtomicArrayQueue<E> extends SequencedAtomicReferenceArrayQueue<E> implements QueueProgressIndicators
| Modifier and Type | Field and Description |
|---|---|
private java.util.concurrent.atomic.AtomicLong |
consumerIndex |
private java.util.concurrent.atomic.AtomicLong |
producerIndex |
sequenceBufferbuffer, mask| Constructor and Description |
|---|
MpmcAtomicArrayQueue(int capacity) |
| Modifier and Type | Method and Description |
|---|---|
protected boolean |
casConsumerIndex(long expect,
long newValue) |
protected boolean |
casProducerIndex(long expect,
long newValue) |
long |
currentConsumerIndex()
This method has no concurrent visibility semantics.
|
long |
currentProducerIndex()
This method has no concurrent visibility semantics.
|
boolean |
isEmpty() |
protected long |
lvConsumerIndex() |
protected long |
lvProducerIndex() |
boolean |
offer(E e) |
E |
peek() |
E |
poll() |
int |
size() |
private static int |
validateCapacity(int capacity) |
calcSequenceOffset, calcSequenceOffset, lvSequence, soSequencecalcElementOffset, calcElementOffset, clear, iterator, lpElement, lpElement, lvElement, lvElement, soElement, soElement, spElement, spElement, svElementcontains, containsAll, remove, removeAll, retainAll, toArray, toArray, toStringclone, equals, finalize, getClass, hashCode, notify, notifyAll, wait, wait, waitprivate final java.util.concurrent.atomic.AtomicLong producerIndex
private final java.util.concurrent.atomic.AtomicLong consumerIndex
private static int validateCapacity(int capacity)
public E poll()
Because return null indicates queue is empty we cannot simply rely on next element visibility for poll and must test producer index when next element is not visible.
poll in interface java.util.Queue<E>public int size()
public boolean isEmpty()
public long currentProducerIndex()
QueueProgressIndicatorscurrentProducerIndex in interface QueueProgressIndicatorspublic long currentConsumerIndex()
QueueProgressIndicatorscurrentConsumerIndex in interface QueueProgressIndicatorsprotected final long lvProducerIndex()
protected final boolean casProducerIndex(long expect,
long newValue)
protected final long lvConsumerIndex()
protected final boolean casConsumerIndex(long expect,
long newValue)