Additional top-level classes in compilation unit: SpscArrayQueueColdField, SpscArrayQueueL1Pad, SpscArrayQueueProducerFields, SpscArrayQueueL2Pad, SpscArrayQueueConsumerField, SpscArrayQueueL3Pad.
This implementation is a mashup of the Fast Flow
algorithm with an optimization of the offer method taken from the BQueue algorithm (a variation on Fast
Flow), and adjusted to comply with Queue.offer semantics with regards to capacity.
For convenience the relevant papers are available in the resources folder:
2010 - Pisa - SPSC Queues on Shared Cache Multi-Core Systems.pdf
2012 - Junchang- BQueue- Efficient and Practical Queuing.pdf
This implementation is wait free.
| Access | Constructor and Description |
|---|---|
| public |
| Modifier and Type | Method and Description |
|---|---|
| public boolean | isEmpty()
Overrides java. Implements rx. |
| private long | |
| private long | |
| public boolean | offer(final E
the Object to enqueue, not null e)Implements rx. Queue#offer(Object) interface.
|
| public E | peek()
Implements rx. Queue#peek() interface.
|
| public E | poll()
Implements rx. Queue#poll() interface.
|
| public int | size()
Implements abstract java. Implements rx. |
| private void | |
| private void |
| SpscArrayQueue | back to summary |
|---|---|
| public SpscArrayQueue(final int capacity) | |
| isEmpty | back to summary |
|---|---|
| public boolean isEmpty() Overrides java. Implements rx. Doc from rx. This method's accuracy is subject to concurrent modifications happening as the observation is carried out.
| |
| lvConsumerIndex | back to summary |
|---|---|
| private long lvConsumerIndex() | |
| lvProducerIndex | back to summary |
|---|---|
| private long lvProducerIndex() | |
| offer | back to summary |
|---|---|
| public boolean offer(final E e) Implements rx. Doc from rx. Called from a producer thread subject to the restrictions appropriate to the implementation and according to the
This implementation is correct for single producer thread use only.
| |
| peek | back to summary |
|---|---|
| public E peek() Implements rx. Doc from rx. Called from the consumer thread subject to the restrictions appropriate to the implementation and according to
the This implementation is correct for single consumer thread use only.
| |
| poll | back to summary |
|---|---|
| public E poll() Implements rx. Doc from rx. Called from the consumer thread subject to the restrictions appropriate to the implementation and according to
the This implementation is correct for single consumer thread use only.
| |
| size | back to summary |
|---|---|
| public int size() Implements abstract java. Implements rx. Doc from rx. 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. For some implementations this method may be O(n) rather than O(1).
| |
| soConsumerIndex | back to summary |
|---|---|
| private void soConsumerIndex(long v) | |
| soProducerIndex | back to summary |
|---|---|
| private void soProducerIndex(long v) | |