E
- public abstract class ConcurrentCircularArrayQueue<E>
extends java.util.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.
|
java.util.Iterator<E> |
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.offer(Object) 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.peek() 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.poll() 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, toString
protected 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 indexprotected final void spElement(long offset, E e)
offset
- computed via calcElementOffset(long)
e
- a kittyprotected final void spElement(E[] buffer, long offset, E e)
buffer
- this.bufferoffset
- computed via calcElementOffset(long)
e
- an orderly kittyprotected final void soElement(long offset, E e)
offset
- computed via calcElementOffset(long)
e
- an orderly kittyprotected final void soElement(E[] buffer, long offset, E e)
buffer
- this.bufferoffset
- computed via calcElementOffset(long)
e
- an orderly kittyprotected final E lpElement(long offset)
offset
- computed via calcElementOffset(long)
protected final E lpElement(E[] buffer, long offset)
buffer
- this.bufferoffset
- 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.bufferoffset
- computed via calcElementOffset(long)
public java.util.Iterator<E> iterator()
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 boundedpublic boolean isEmpty()