E -
public abstract class ConcurrentCircularArrayQueue<E> extends AbstractQueue<E>
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.
| Modifier and Type | Field and Description |
|---|---|
protected E[] |
buffer
|
protected static int |
BUFFER_PAD
|
protected int |
capacity
|
protected long |
mask
|
protected static int |
SPARSE_SHIFT
|
| Constructor and Description |
|---|
ConcurrentCircularArrayQueue(int capacity)
|
| Modifier and Type | Method and Description |
|---|---|
protected long |
calcElementOffset(long index)
|
boolean |
isEmpty()
This method's accuracy is subject to concurrent modifications happening as the observation is carried out.
|
Iterator |
iterator()
|
protected E |
lpElement(E[] buffer, long offset)
A plain load (no ordering/fences) of an element from a given offset.
|
protected E |
lpElement(long offset)
A plain load (no ordering/fences) of an element from a given offset.
|
protected E |
lvElement(E[] buffer, long offset)
A volatile load (load + LoadLoad barrier) of an element from a given offset.
|
protected E |
lvElement(long offset)
A volatile load (load + LoadLoad barrier) of an element from a given offset.
|
boolean |
offer(M message)
Called from a producer thread subject to the restrictions appropriate to the implementation and according to the
Queue interface (but failure to offer doesn't necessitate queue is full).
|
M |
peek()
Called from the consumer thread subject to the restrictions appropriate to the implementation and according to the
Queue interface (barring the hard requirement on null returns).
|
M |
poll()
Called from the consumer thread subject to the restrictions appropriate to the implementation and according to the
Queue interface (barring the hard requirement on null returns).
|
int |
size()
This method's accuracy is subject to concurrent modifications happening as the size is estimated and as such is a best effort rather than absolute value.
|
protected void |
soElement(E[] buffer, long offset, E e)
An ordered store(store + StoreStore barrier) of an element to a given offset
|
protected void |
soElement(long offset, E e)
An ordered store(store + StoreStore barrier) of an element to a given offset
|
protected void |
spElement(E[] buffer, long offset, E e)
A plain store (no ordering/fences) of an element to a given offset
|
protected void |
spElement(long offset, E e)
A plain store (no ordering/fences) of an element to a given offset
|
contains, containsAll, isEmpty, remove, removeAll, retainAll, size, toArray, toArray, toStringclone, equals, finalize, getClass, hashCode, notify, notifyAll, wait, wait, waitcontains, containsAll, equals, hashCode, isEmpty, parallelStream, remove, removeAll, removeIf, retainAll, size, spliterator, stream, toArray, toArrayprotected static final int SPARSE_SHIFT
protected static final int BUFFER_PAD
protected final int capacity
protected final long mask
protected final E[] buffer
protected final long calcElementOffset(long index)
index - desirable element index
protected final void spElement(long offset,
E e)
offset - computed via
calcElementOffset(long)
e - a kitty
protected final void spElement(E[] buffer, long offset, E e)
buffer - this.buffer
offset - computed via
calcElementOffset(long)
e - an orderly kitty
protected final void soElement(long offset,
E e)
offset - computed via
calcElementOffset(long)
e - an orderly kitty
protected final void soElement(E[] buffer, long offset, E e)
buffer - this.buffer
offset - computed via
calcElementOffset(long)
e - an orderly kitty
protected final E lpElement(long offset)
offset - computed via
calcElementOffset(long)
protected final E lpElement(E[] buffer, long offset)
buffer - this.buffer
offset - computed via
calcElementOffset(long)
protected final E lvElement(long offset)
offset - computed via
calcElementOffset(long)
protected final E lvElement(E[] buffer, long offset)
buffer - this.buffer
offset - computed via
calcElementOffset(long)
public boolean offer(M message)
Queue.offer(Object) interface (but failure to offer doesn't necessitate queue is full).
message -
public M poll()
Queue.poll() interface (barring the hard requirement on null returns).
public M peek()
Queue.peek() interface (barring the hard requirement on null returns).
public int size()
Integer.MAX_VALUE if not bounded
public boolean isEmpty()