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 booleanisEmpty()iterator()protected final LinkedQueueNode<E> protected final LinkedQueueNode<E> protected final LinkedQueueNode<E> protected final LinkedQueueNode<E> final intsize()protected final voidspConsumerNode(LinkedQueueNode<E> node) protected final voidspProducerNode(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, toStringMethods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, wait, wait, waitMethods 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:
iteratorin interfaceCollection<E>- Specified by:
iteratorin interfaceIterable<E>- Specified by:
iteratorin 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:
sizein interfaceCollection<E>- Specified by:
sizein 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:
isEmptyin interfaceCollection<E>- Overrides:
isEmptyin classAbstractCollection<E>
-