E
- public final class MpscLinkedAtomicQueue<E> extends AbstractQueue<E>
Constructor and Description |
---|
MpscLinkedAtomicQueue() |
Modifier and Type | Method and Description |
---|---|
protected E |
getSingleConsumerNodeValue(LinkedQueueAtomicNode<E> currConsumerNode,
LinkedQueueAtomicNode<E> nextNode) |
boolean |
isEmpty()
|
Iterator<E> |
iterator() |
protected LinkedQueueAtomicNode<E> |
lpConsumerNode() |
protected LinkedQueueAtomicNode<E> |
lpProducerNode() |
protected LinkedQueueAtomicNode<E> |
lvConsumerNode() |
protected LinkedQueueAtomicNode<E> |
lvProducerNode() |
boolean |
offer(E e)
|
E |
peek() |
E |
poll()
|
int |
size()
|
protected void |
spConsumerNode(LinkedQueueAtomicNode<E> node) |
protected void |
spProducerNode(LinkedQueueAtomicNode<E> node) |
protected LinkedQueueAtomicNode<E> |
xchgProducerNode(LinkedQueueAtomicNode<E> node) |
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
public final boolean offer(E e)
IMPLEMENTATION NOTES:
Offer is allowed from multiple threads.
Offer allocates a new node and:
public final E poll()
IMPLEMENTATION NOTES:
Poll is allowed from a SINGLE thread.
Poll reads the next node from the consumerNode and:
MessagePassingQueue.poll()
,
Queue.poll()
public final E peek()
protected final LinkedQueueAtomicNode<E> lvProducerNode()
protected final LinkedQueueAtomicNode<E> lpProducerNode()
protected final void spProducerNode(LinkedQueueAtomicNode<E> node)
protected final LinkedQueueAtomicNode<E> xchgProducerNode(LinkedQueueAtomicNode<E> node)
protected final LinkedQueueAtomicNode<E> lvConsumerNode()
protected final LinkedQueueAtomicNode<E> lpConsumerNode()
protected final void spConsumerNode(LinkedQueueAtomicNode<E> node)
public final Iterator<E> iterator()
iterator
in interface Iterable<E>
iterator
in interface Collection<E>
iterator
in class AbstractCollection<E>
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()
protected E getSingleConsumerNodeValue(LinkedQueueAtomicNode<E> currConsumerNode, LinkedQueueAtomicNode<E> nextNode)
Copyright © 2013–2018. All rights reserved.