Package rx.internal.util.unsafe
Class ConcurrentCircularArrayQueue<E>
java.lang.Object
java.util.AbstractCollection<E>
java.util.AbstractQueue<E>
rx.internal.util.unsafe.ConcurrentCircularArrayQueueL0Pad<E>
rx.internal.util.unsafe.ConcurrentCircularArrayQueue<E>
- Type Parameters:
E- the element type
- All Implemented Interfaces:
Iterable<E>,Collection<E>,Queue<E>,MessagePassingQueue<E>
- Direct Known Subclasses:
ConcurrentSequencedCircularArrayQueue,SpmcArrayQueueL1Pad,SpscArrayQueueColdField
@SuppressAnimalSniffer
public abstract class ConcurrentCircularArrayQueue<E>
extends ConcurrentCircularArrayQueueL0Pad<E>
A concurrent access enabling class used by circular array based queues this class exposes an offset computation
method along with differently memory fenced load/store methods into the underlying array. The class is pre-padded and
the array is padded on either side to help with False sharing prevention. It is expected that subclasses handle post
padding.
Offset calculation is separate from access to enable the reuse of a give compute offset.
Load/Store methods using a buffer parameter are provided to allow the prevention of final field reload after a LoadLoad barrier.
-
Field Summary
FieldsModifier and TypeFieldDescriptionprotected final E[]protected static final intprotected final longprivate static final longprivate static final intprotected static final int -
Constructor Summary
Constructors -
Method Summary
Modifier and TypeMethodDescriptionprotected final longcalcElementOffset(long index) protected final longcalcElementOffset(long index, long mask) voidclear()iterator()protected final ElpElement(long offset) A plain load (no ordering/fences) of an element from a given offset.protected final EA plain load (no ordering/fences) of an element from a given offset.protected final ElvElement(long offset) A volatile load (load + LoadLoad barrier) of an element from a given offset.protected final EA volatile load (load + LoadLoad barrier) of an element from a given offset.protected final voidAn ordered store(store + StoreStore barrier) of an element to a given offsetprotected final voidAn ordered store(store + StoreStore barrier) of an element to a given offsetprotected final voidA plain store (no ordering/fences) of an element to a given offsetprotected final voidA plain store (no ordering/fences) of an element to a given offsetMethods inherited from class java.util.AbstractQueue
add, addAll, element, removeMethods inherited from class java.util.AbstractCollection
contains, containsAll, isEmpty, remove, removeAll, retainAll, size, 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, isEmpty, parallelStream, remove, removeAll, removeIf, retainAll, size, spliterator, stream, toArray, toArray, toArray
-
Field Details
-
SPARSE_SHIFT
protected static final int SPARSE_SHIFT -
BUFFER_PAD
protected static final int BUFFER_PAD- See Also:
-
REF_ARRAY_BASE
private static final long REF_ARRAY_BASE -
REF_ELEMENT_SHIFT
private static final int REF_ELEMENT_SHIFT -
mask
protected final long mask -
buffer
-
-
Constructor Details
-
ConcurrentCircularArrayQueue
public ConcurrentCircularArrayQueue(int capacity)
-
-
Method Details
-
calcElementOffset
protected final long calcElementOffset(long index) - Parameters:
index- desirable element index- Returns:
- the offset in bytes within the array for a given index.
-
calcElementOffset
protected final long calcElementOffset(long index, long mask) - Parameters:
index- desirable element indexmask-- Returns:
- the offset in bytes within the array for a given index.
-
spElement
A plain store (no ordering/fences) of an element to a given offset- Parameters:
offset- computed viacalcElementOffset(long)e- a kitty
-
spElement
A plain store (no ordering/fences) of an element to a given offset- Parameters:
buffer- this.bufferoffset- computed viacalcElementOffset(long)e- an orderly kitty
-
soElement
An ordered store(store + StoreStore barrier) of an element to a given offset- Parameters:
offset- computed viacalcElementOffset(long)e- an orderly kitty
-
soElement
An ordered store(store + StoreStore barrier) of an element to a given offset- Parameters:
buffer- this.bufferoffset- computed viacalcElementOffset(long)e- an orderly kitty
-
lpElement
A plain load (no ordering/fences) of an element from a given offset.- Parameters:
offset- computed viacalcElementOffset(long)- Returns:
- the element at the offset
-
lpElement
A plain load (no ordering/fences) of an element from a given offset.- Parameters:
buffer- this.bufferoffset- computed viacalcElementOffset(long)- Returns:
- the element at the offset
-
lvElement
A volatile load (load + LoadLoad barrier) of an element from a given offset.- Parameters:
offset- computed viacalcElementOffset(long)- Returns:
- the element at the offset
-
lvElement
A volatile load (load + LoadLoad barrier) of an element from a given offset.- Parameters:
buffer- this.bufferoffset- computed viacalcElementOffset(long)- Returns:
- the element at the offset
-
iterator
- Specified by:
iteratorin interfaceCollection<E>- Specified by:
iteratorin interfaceIterable<E>- Specified by:
iteratorin classAbstractCollection<E>
-
clear
public void clear()- Specified by:
clearin interfaceCollection<E>- Overrides:
clearin classAbstractQueue<E>
-