E
- public final class MpscAtomicArrayQueue<E> extends AtomicReferenceArrayQueue<E> implements QueueProgressIndicators
AtomicReferenceArrayQueue
. This implies that
any thread may call the offer method, but only a single thread may call poll/peek for correctness to
maintained. Modifier and Type | Field and Description |
---|---|
private java.util.concurrent.atomic.AtomicLong |
consumerIndex |
private long |
headCache |
private java.util.concurrent.atomic.AtomicLong |
producerIndex |
buffer, mask
Constructor and Description |
---|
MpscAtomicArrayQueue(int capacity) |
Modifier and Type | Method and Description |
---|---|
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() |
private long |
lvConsumerIndex() |
protected long |
lvConsumerIndexCache() |
private long |
lvProducerIndex() |
boolean |
offer(E e)
IMPLEMENTATION NOTES: Lock free offer using a single CAS. |
E |
peek() |
E |
poll() |
int |
size() |
protected void |
soConsumerIndex(long l) |
protected void |
svConsumerIndexCache(long v) |
int |
weakOffer(E e)
A wait free alternative to offer which fails on CAS failure.
|
calcElementOffset, calcElementOffset, clear, iterator, lpElement, lpElement, lvElement, lvElement, soElement, soElement, spElement, spElement, svElement, toString
contains, containsAll, remove, removeAll, retainAll, toArray, toArray
clone, equals, finalize, getClass, hashCode, notify, notifyAll, wait, wait, wait
private final java.util.concurrent.atomic.AtomicLong consumerIndex
private final java.util.concurrent.atomic.AtomicLong producerIndex
private volatile long headCache
public boolean offer(E e)
offer
in interface java.util.Queue<E>
Queue.offer(java.lang.Object)
,
MessagePassingQueue.offer(Object)
public final int weakOffer(E e)
e
- new element, not nullpublic E poll()
IMPLEMENTATION NOTES:
Lock free poll using ordered loads/stores. As class name suggests access is limited to a single thread.
poll
in interface java.util.Queue<E>
Queue.poll()
,
MessagePassingQueue.poll()
public E peek()
IMPLEMENTATION NOTES:
Lock free peek using ordered loads. As class name suggests access is limited to a single thread.
peek
in interface java.util.Queue<E>
Queue.poll()
,
MessagePassingQueue.poll()
public int size()
public boolean isEmpty()
public long currentProducerIndex()
QueueProgressIndicators
currentProducerIndex
in interface QueueProgressIndicators
public long currentConsumerIndex()
QueueProgressIndicators
currentConsumerIndex
in interface QueueProgressIndicators
private long lvConsumerIndex()
private long lvProducerIndex()
protected final long lvConsumerIndexCache()
protected final void svConsumerIndexCache(long v)
protected final boolean casProducerIndex(long expect, long newValue)
protected void soConsumerIndex(long l)