This implementation is based on JCTools' SPSC algorithms: SpscUnboundedArrayQueue
and SpscUnboundedAtomicArrayQueue
of which the SpscUnboundedAtomicArrayQueue was contributed by one of the
authors of this library. The notable difference is that this class is not padded and
there is no lookahead cache involved; padding has a toll on short lived or bursty uses
and lookahead doesn't really matter with small queues.
| Modifier and Type | Field and Description |
|---|---|
| pack-priv static final AtomicLongFieldUpdater | |
| pack-priv AtomicReferenceArray | |
| pack-priv volatile long | |
| pack-priv final int | |
| pack-priv static final Object | |
| pack-priv static final AtomicLongFieldUpdater | |
| pack-priv AtomicReferenceArray | |
| pack-priv volatile long |
| Access | Constructor and Description |
|---|---|
| pack-priv |
| Modifier and Type | Method and Description |
|---|---|
| public void | clear()
Overrides java. Implements java. |
| public boolean | isEmpty()
Overrides java. Implements java. true if this collection contains no elements.
|
| public Iterator | iterator()
Implements abstract java. Implements java. |
| public boolean | offer(T
the element to add e)Implements java. |
| public T | peek()
Implements java. null if this queue is empty.
|
| public T | poll()
Implements java. null if this queue is empty.
|
| public int | size()
Implements abstract java. Implements java. |
| public boolean | Returns: true if the queue accepted the two new valuesthe first value, not null first, T the second value, not null second)Implements java. |
| CONSUMER_INDEX | back to summary |
|---|---|
pack-priv static final AtomicLongFieldUpdater<SpscLinkedArrayQueue<T>> CONSUMER_INDEX
| |
| consumerArray | back to summary |
|---|---|
| pack-priv AtomicReferenceArray<Object> consumerArray | |
| consumerIndex | back to summary |
|---|---|
| pack-priv volatile long consumerIndex | |
| mask | back to summary |
|---|---|
| pack-priv final int mask | |
| NEXT | back to summary |
|---|---|
| pack-priv static final Object NEXT | |
| PRODUCER_INDEX | back to summary |
|---|---|
pack-priv static final AtomicLongFieldUpdater<SpscLinkedArrayQueue<T>> PRODUCER_INDEX
| |
| producerArray | back to summary |
|---|---|
| pack-priv AtomicReferenceArray<Object> producerArray | |
| producerIndex | back to summary |
|---|---|
| pack-priv volatile long producerIndex | |
| SpscLinkedArrayQueue | back to summary |
|---|---|
| pack-priv SpscLinkedArrayQueue(int linkSize) | |
| clear | back to summary |
|---|---|
| public void clear() Overrides java. Implements java. Doc from java. Removes all of the elements from this queue. The queue will be empty after this call returns. This implementation repeatedly invokes
| |
| isEmpty | back to summary |
|---|---|
| public boolean isEmpty() Overrides java. Implements java. Doc from java. Returns
| |
| iterator | back to summary |
|---|---|
| public Iterator Implements abstract java. Implements java. Doc from java. Returns an iterator over the elements in this collection. There are no guarantees concerning the order in which the elements are returned (unless this collection is an instance of some class that provides a guarantee). | |
| offer | back to summary |
|---|---|
| public boolean offer(T e) Implements java. Doc from java. Inserts the specified element into this queue if it is possible to do
so immediately without violating capacity restrictions.
When using a capacity-restricted queue, this method is generally
preferable to
| |
| peek | back to summary |
|---|---|
| public T peek() Implements java. Doc from java. Retrieves, but does not remove, the head of this queue,
or returns
| |
| poll | back to summary |
|---|---|
| public T poll() Implements java. Doc from java. Retrieves and removes the head of this queue,
or returns
| |
| size | back to summary |
|---|---|
| public int size() Implements abstract java. Implements java. Doc from java. Returns the number of elements in this collection. If this collection
contains more than
| |
| test | back to summary |
|---|---|
| public boolean test(T first, T second) Implements java. Offer two elements at the same time. Don't use the regular offer() with this at all!
| |