public class SpscChunkedAtomicArrayQueue<E> extends AbstractQueue<E>
Modifier and Type | Field and Description |
---|---|
protected AtomicReferenceArray<E> |
consumerBuffer |
protected long |
consumerIndex |
protected long |
consumerMask |
protected static Object |
JUMP |
protected AtomicReferenceArray<E> |
producerBuffer |
protected long |
producerBufferLimit |
protected long |
producerIndex |
protected long |
producerMask |
Constructor and Description |
---|
SpscChunkedAtomicArrayQueue(int capacity) |
SpscChunkedAtomicArrayQueue(int chunkSize,
int capacity) |
Modifier and Type | Method and Description |
---|---|
protected static <E> AtomicReferenceArray<E> |
allocate(int capacity) |
protected static int |
calcElementOffset(long index,
long mask) |
long |
currentConsumerIndex()
This method has no concurrent visibility semantics.
|
long |
currentProducerIndex()
This method has no concurrent visibility semantics.
|
boolean |
isEmpty() |
Iterator<E> |
iterator() |
protected void |
linkOldToNew(long currIndex,
AtomicReferenceArray<E> oldBuffer,
int offset,
AtomicReferenceArray<E> newBuffer,
int offsetInNew,
E e) |
long |
lvConsumerIndex() |
protected E |
lvElement(AtomicReferenceArray<E> buffer,
int offset) |
protected AtomicReferenceArray<E> |
lvNextArrayAndUnlink(AtomicReferenceArray curr) |
long |
lvProducerIndex() |
boolean |
offer(E e) |
protected boolean |
offerColdPath(AtomicReferenceArray<E> buffer,
long mask,
E e,
long pIndex,
int offset) |
E |
peek() |
E |
poll() |
int |
size() |
protected void |
soConsumerIndex(long v) |
protected void |
soNext(AtomicReferenceArray<E> curr,
AtomicReferenceArray<E> next) |
protected void |
soProducerIndex(long v) |
String |
toString() |
protected void |
writeToQueue(AtomicReferenceArray<E> buffer,
E e,
long index,
int offset) |
contains, containsAll, remove, removeAll, retainAll, toArray, toArray
clone, equals, finalize, getClass, hashCode, notify, notifyAll, wait, wait, wait
contains, containsAll, equals, hashCode, parallelStream, remove, removeAll, removeIf, retainAll, spliterator, stream, toArray, toArray
protected static final Object JUMP
protected long producerBufferLimit
protected long producerMask
protected AtomicReferenceArray<E> producerBuffer
protected volatile long producerIndex
protected volatile long consumerIndex
protected long consumerMask
protected AtomicReferenceArray<E> consumerBuffer
public SpscChunkedAtomicArrayQueue(int capacity)
public SpscChunkedAtomicArrayQueue(int chunkSize, int capacity)
protected final boolean offerColdPath(AtomicReferenceArray<E> buffer, long mask, E e, long pIndex, int offset)
protected final void soProducerIndex(long v)
protected final void soConsumerIndex(long v)
public final long lvProducerIndex()
lvProducerIndex
in interface IndexedQueueSizeUtil.IndexedQueue
public final long lvConsumerIndex()
lvConsumerIndex
in interface IndexedQueueSizeUtil.IndexedQueue
protected static <E> AtomicReferenceArray<E> allocate(int capacity)
public final Iterator<E> iterator()
iterator
in interface Iterable<E>
iterator
in interface Collection<E>
iterator
in class AbstractCollection<E>
public String toString()
toString
in class AbstractCollection<E>
public long currentProducerIndex()
QueueProgressIndicators
currentProducerIndex
in interface QueueProgressIndicators
public long currentConsumerIndex()
QueueProgressIndicators
currentConsumerIndex
in interface QueueProgressIndicators
protected final void soNext(AtomicReferenceArray<E> curr, AtomicReferenceArray<E> next)
protected final AtomicReferenceArray<E> lvNextArrayAndUnlink(AtomicReferenceArray curr)
public boolean offer(E e)
This implementation is correct for single producer thread use only.
protected final void linkOldToNew(long currIndex, AtomicReferenceArray<E> oldBuffer, int offset, AtomicReferenceArray<E> newBuffer, int offsetInNew, E e)
protected final void writeToQueue(AtomicReferenceArray<E> buffer, E e, long index, int offset)
public E poll()
This implementation is correct for single consumer thread use only.
protected E lvElement(AtomicReferenceArray<E> buffer, int offset)
protected static int calcElementOffset(long index, long mask)
public E peek()
This implementation is correct for single consumer thread use only.
public final int size()
size
in interface Collection<E>
size
in class AbstractCollection<E>
public final boolean isEmpty()
isEmpty
in interface Collection<E>
isEmpty
in class AbstractCollection<E>
Copyright © 2013–2017. All rights reserved.