E -
public final class SpscLinkedAtomicQueue<E> extends AbstractQueue<E>
| Constructor and Description |
|---|
SpscLinkedAtomicQueue()
|
| Modifier and Type | Method and Description |
|---|---|
boolean |
isEmpty()
|
Iterator |
iterator()
|
protected LinkedQueueNode |
lpConsumerNode()
|
protected LinkedQueueNode |
lpProducerNode()
|
protected LinkedQueueNode |
lvConsumerNode()
|
protected LinkedQueueNode |
lvProducerNode()
|
boolean |
offer(E nextValue)
IMPLEMENTATION NOTES: Offer is allowed from a SINGLE thread. Offer allocates a new node (holding the offered value) and: Sets that node as the producerNode.next Sets the new node as the producerNode From this follows that producerNode.next is always null and for all other nodes node.next is not null. |
E |
peek()
|
E |
poll()
IMPLEMENTATION NOTES: Poll is allowed from a SINGLE thread. Poll reads the next node from the consumerNode and: If it is null, the queue is empty. |
int |
size()
|
protected void |
spConsumerNode(LinkedQueueNode
|
protected void |
spProducerNode(LinkedQueueNode
|
protected LinkedQueueNode |
xchgProducerNode(LinkedQueueNode
|
contains, containsAll, remove, removeAll, retainAll, toArray, toArray, toStringclone, equals, finalize, getClass, hashCode, notify, notifyAll, wait, wait, waitcontains, containsAll, equals, hashCode, parallelStream, remove, removeAll, removeIf, retainAll, spliterator, stream, toArray, toArraypublic boolean offer(E nextValue)
MessagePassingQueue#offer(Object),
Queue.offer(java.lang.Object)
public E poll()
public E peek()
protected final LinkedQueueNode<E> lvProducerNode()
protected final LinkedQueueNode<E> lpProducerNode()
protected final void spProducerNode(LinkedQueueNode<E> node)
protected final LinkedQueueNode<E> xchgProducerNode(LinkedQueueNode <E> node)
protected final LinkedQueueNode<E> lvConsumerNode()
protected final LinkedQueueNode<E> lpConsumerNode()
protected final void spConsumerNode(LinkedQueueNode<E> node)
public final Iterator<E> iterator()
public final int size()
IMPLEMENTATION NOTES:
This is an O(n) operation as we run through all the nodes and count them.
size in interface
Collection<E>
size in class
AbstractCollection<E>
Collection.size()
public final boolean isEmpty()
IMPLEMENTATION NOTES:
Queue is empty when producerNode is the same as consumerNode. An alternative implementation would be to observe the producerNode.value is null, which also means an empty queue because only the consumerNode.value is allowed to be null.
isEmpty in interface
Collection<E>
isEmpty in class
AbstractCollection<E>
MessagePassingQueue#isEmpty()