-
- 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 booleanoffer(T e)This implementation is correct for single producer thread use only. Tpoll()This implementation is correct for single consumer thread use only. Tpeek()This implementation is correct for single consumer thread use only. voidclear()intsize()booleanisEmpty()Iterator<T>iterator()booleancontains(Object o)Array<Object>toArray()<E> Array<E>toArray(Array<E> a)booleanremove(Object o)booleancontainsAll(Collection<out Object> c)booleanaddAll(Collection<out T> c)booleanremoveAll(Collection<out Object> c)booleanretainAll(Collection<out Object> c)booleanadd(T e)Tremove()Telement()-
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)
-
-
-
-