E - public final class SpscArrayQueue<E> extends ConcurrentCircularArrayQueue<E>
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.
| Modifier and Type | Field and Description |
|---|---|
protected long |
consumerIndex |
protected int |
lookAheadStep |
protected long |
producerIndex |
protected long |
producerLookAhead |
buffer, BUFFER_PAD, capacity, mask, SPARSE_SHIFT| Constructor and Description |
|---|
SpscArrayQueue(int capacity) |
| Modifier and Type | Method and Description |
|---|---|
boolean |
isEmpty()
This method's accuracy is subject to concurrent modifications happening as the observation is carried out.
|
protected long |
lvConsumerIndex() |
protected long |
lvProducerIndex() |
boolean |
offer(E e) |
E |
peek() |
E |
poll() |
int |
size() |
calcElementOffset, clear, iterator, lpElement, lpElement, lvElement, lvElement, soElement, soElement, spElement, spElementadd, addAll, element, removecontains, containsAll, isEmpty, remove, removeAll, retainAll, toArray, toArray, toStringclone, equals, finalize, getClass, hashCode, notify, notifyAll, wait, wait, waitcontains, containsAll, equals, hashCode, isEmpty, parallelStream, remove, removeAll, removeIf, retainAll, spliterator, stream, toArray, toArrayprotected long consumerIndex
protected long producerIndex
protected long producerLookAhead
protected final int lookAheadStep
public boolean offer(E e)
This implementation is correct for single producer thread use only.
public E poll()
This implementation is correct for single consumer thread use only.
public E peek()
This implementation is correct for single consumer thread use only.
public int size()
size in interface Collection<E>size in class AbstractCollection<E>protected final long lvConsumerIndex()
protected final long lvProducerIndex()
public boolean isEmpty()
Copyright © 2013–2014. All rights reserved.