E
- public final class MpscAtomicArrayQueue<E> extends AbstractQueue<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 |
---|---|
protected AtomicReferenceArray<E> |
buffer |
protected int |
mask |
Constructor and Description |
---|
MpscAtomicArrayQueue(int capacity) |
Modifier and Type | Method and Description |
---|---|
protected int |
calcElementOffset(long index) |
protected int |
calcElementOffset(long index,
int mask) |
protected boolean |
casProducerIndex(long expect,
long newValue) |
void |
clear() |
long |
currentConsumerIndex()
This method has no concurrent visibility semantics.
|
long |
currentProducerIndex()
This method has no concurrent visibility semantics.
|
boolean |
isEmpty() |
Iterator<E> |
iterator() |
protected E |
lpElement(AtomicReferenceArray<E> buffer,
int offset) |
protected E |
lpElement(int offset) |
protected long |
lvConsumerIndexCache() |
protected E |
lvElement(AtomicReferenceArray<E> buffer,
int offset) |
protected E |
lvElement(int offset) |
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 |
soElement(AtomicReferenceArray<E> buffer,
int offset,
E value) |
protected void |
soElement(int offset,
E value) |
protected void |
spElement(AtomicReferenceArray<E> buffer,
int offset,
E value) |
protected void |
spElement(int offset,
E value) |
protected void |
svConsumerIndexCache(long v) |
protected void |
svElement(AtomicReferenceArray<E> buffer,
int offset,
E value) |
int |
weakOffer(E e)
A wait free alternative to offer which fails on CAS failure.
|
add, addAll, element, remove
contains, containsAll, remove, removeAll, retainAll, toArray, toArray, toString
clone, equals, finalize, getClass, hashCode, notify, notifyAll, wait, wait, wait
contains, containsAll, equals, hashCode, parallelStream, remove, removeAll, removeIf, retainAll, spliterator, stream, toArray, toArray
protected final AtomicReferenceArray<E> buffer
protected final int mask
public boolean offer(E e)
offer
in interface 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 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 Queue<E>
Queue.poll()
,
MessagePassingQueue.poll()
public int size()
size
in interface Collection<E>
size
in class AbstractCollection<E>
public boolean isEmpty()
isEmpty
in interface Collection<E>
isEmpty
in class AbstractCollection<E>
public long currentProducerIndex()
QueueProgressIndicators
currentProducerIndex
in interface QueueProgressIndicators
public long currentConsumerIndex()
QueueProgressIndicators
currentConsumerIndex
in interface QueueProgressIndicators
protected final long lvConsumerIndexCache()
protected final void svConsumerIndexCache(long v)
protected final boolean casProducerIndex(long expect, long newValue)
protected void soConsumerIndex(long l)
public Iterator<E> iterator()
iterator
in interface Iterable<E>
iterator
in interface Collection<E>
iterator
in class AbstractCollection<E>
public void clear()
clear
in interface Collection<E>
clear
in class AbstractQueue<E>
protected final int calcElementOffset(long index, int mask)
protected final int calcElementOffset(long index)
protected final E lvElement(AtomicReferenceArray<E> buffer, int offset)
protected final E lpElement(AtomicReferenceArray<E> buffer, int offset)
protected final E lpElement(int offset)
protected final void spElement(AtomicReferenceArray<E> buffer, int offset, E value)
protected final void spElement(int offset, E value)
protected final void soElement(AtomicReferenceArray<E> buffer, int offset, E value)
protected final void soElement(int offset, E value)
protected final void svElement(AtomicReferenceArray<E> buffer, int offset, E value)
protected final E lvElement(int offset)
Copyright © 2013-2016. All Rights Reserved.