Package rx.internal.util.atomic
Class BaseLinkedAtomicQueue<E>
java.lang.Object
java.util.AbstractCollection<E>
java.util.AbstractQueue<E>
rx.internal.util.atomic.BaseLinkedAtomicQueue<E>
- All Implemented Interfaces:
Iterable<E>
,Collection<E>
,Queue<E>
- Direct Known Subclasses:
MpscLinkedAtomicQueue
,SpscLinkedAtomicQueue
-
Field Summary
FieldsModifier and TypeFieldDescriptionprivate final AtomicReference
<LinkedQueueNode<E>> private final AtomicReference
<LinkedQueueNode<E>> -
Constructor Summary
Constructors -
Method Summary
Modifier and TypeMethodDescriptionfinal boolean
isEmpty()
iterator()
protected final LinkedQueueNode
<E> protected final LinkedQueueNode
<E> protected final LinkedQueueNode
<E> protected final LinkedQueueNode
<E> final int
size()
protected final void
spConsumerNode
(LinkedQueueNode<E> node) protected final void
spProducerNode
(LinkedQueueNode<E> node) protected final LinkedQueueNode
<E> xchgProducerNode
(LinkedQueueNode<E> node) Methods inherited from class java.util.AbstractCollection
contains, containsAll, remove, removeAll, retainAll, toArray, toArray, toString
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, wait, wait, wait
Methods inherited from interface java.util.Collection
contains, containsAll, equals, hashCode, parallelStream, remove, removeAll, removeIf, retainAll, spliterator, stream, toArray, toArray, toArray
-
Field Details
-
producerNode
-
consumerNode
-
-
Constructor Details
-
BaseLinkedAtomicQueue
public BaseLinkedAtomicQueue()
-
-
Method Details
-
lvProducerNode
-
lpProducerNode
-
spProducerNode
-
xchgProducerNode
-
lvConsumerNode
-
lpConsumerNode
-
spConsumerNode
-
iterator
- Specified by:
iterator
in interfaceCollection<E>
- Specified by:
iterator
in interfaceIterable<E>
- Specified by:
iterator
in classAbstractCollection<E>
-
size
public final int size()
IMPLEMENTATION NOTES:
This is an O(n) operation as we run through all the nodes and count them.- Specified by:
size
in interfaceCollection<E>
- Specified by:
size
in classAbstractCollection<E>
- See Also:
-
isEmpty
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.- Specified by:
isEmpty
in interfaceCollection<E>
- Overrides:
isEmpty
in classAbstractCollection<E>
-