-
- All Implemented Interfaces:
-
java.lang.Iterable
,java.util.Collection
,java.util.Queue
public final class SpscUnboundedAtomicArrayQueue<T> implements Queue<T>
A single-producer single-consumer queue with unbounded capacity.
The implementation uses fixed, power-of-2 arrays to store elements and turns into a linked-list like structure if the production overshoots the consumption.
Note that the minimum capacity of the 'islands' are 8 due to how the look-ahead optimization works.
The implementation uses field updaters and thus should be platform-safe.
-
-
Constructor Summary
Constructors Constructor Description SpscUnboundedAtomicArrayQueue(int bufferSize)
-
Method Summary
Modifier and Type Method Description boolean
offer(T e)
This implementation is correct for single producer thread use only. T
poll()
This implementation is correct for single consumer thread use only. T
peek()
This implementation is correct for single consumer thread use only. void
clear()
int
size()
boolean
isEmpty()
Iterator<T>
iterator()
boolean
contains(Object o)
Array<Object>
toArray()
<E> Array<E>
toArray(Array<E> a)
boolean
remove(Object o)
boolean
containsAll(Collection<out Object> c)
boolean
addAll(Collection<out T> c)
boolean
removeAll(Collection<out Object> c)
boolean
retainAll(Collection<out Object> c)
boolean
add(T e)
T
remove()
T
element()
-
Methods inherited from class java.util.Queue
add, element, offer, peek, poll, remove
-
Methods inherited from class java.util.Collection
addAll, clear, contains, containsAll, isEmpty, iterator, parallelStream, remove, removeAll, removeIf, retainAll, size, spliterator, stream, toArray, toArray
-
Methods inherited from class java.lang.Iterable
forEach, iterator, spliterator
-
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
-
-
Method Detail
-
clear
void clear()
-
size
int size()
-
isEmpty
boolean isEmpty()
-
containsAll
boolean containsAll(Collection<out Object> c)
-
addAll
boolean addAll(Collection<out T> c)
-
removeAll
boolean removeAll(Collection<out Object> c)
-
retainAll
boolean retainAll(Collection<out Object> c)
-
-
-
-