Package rx.internal.util.atomic
Class SpscExactAtomicArrayQueue<T>
java.lang.Object
java.util.concurrent.atomic.AtomicReferenceArray<T>
rx.internal.util.atomic.SpscExactAtomicArrayQueue<T>
- Type Parameters:
T- the value type held by this queue
- All Implemented Interfaces:
Serializable,Iterable<T>,Collection<T>,Queue<T>
A single-producer single-consumer bounded queue with exact capacity tracking.
This means that a queue of 10 will allow exactly 10 offers, however, the underlying storage is still power-of-2.
The implementation uses field updaters and thus should be platform-safe.
- See Also:
-
Field Summary
FieldsModifier and TypeFieldDescription(package private) final int(package private) final AtomicLong(package private) final int(package private) final AtomicLongprivate static final long -
Constructor Summary
Constructors -
Method Summary
Modifier and TypeMethodDescriptionbooleanbooleanaddAll(Collection<? extends T> c) voidclear()booleanbooleancontainsAll(Collection<?> c) element()booleanisEmpty()iterator()booleanpeek()poll()remove()booleanbooleanremoveAll(Collection<?> c) booleanretainAll(Collection<?> c) intsize()Object[]toArray()<E> E[]toArray(E[] a) Methods inherited from class java.util.concurrent.atomic.AtomicReferenceArray
accumulateAndGet, compareAndExchange, compareAndExchangeAcquire, compareAndExchangeRelease, compareAndSet, get, getAcquire, getAndAccumulate, getAndSet, getAndUpdate, getOpaque, getPlain, lazySet, length, set, setOpaque, setPlain, setRelease, toString, updateAndGet, weakCompareAndSet, weakCompareAndSetAcquire, weakCompareAndSetPlain, weakCompareAndSetRelease, weakCompareAndSetVolatileMethods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, wait, wait, waitMethods inherited from interface java.util.Collection
equals, hashCode, parallelStream, removeIf, spliterator, stream, toArray
-
Field Details
-
serialVersionUID
private static final long serialVersionUID- See Also:
-
mask
final int mask -
capacitySkip
final int capacitySkip -
producerIndex
-
consumerIndex
-
-
Constructor Details
-
SpscExactAtomicArrayQueue
public SpscExactAtomicArrayQueue(int capacity)
-
-
Method Details
-
offer
-
poll
-
peek
-
clear
public void clear()- Specified by:
clearin interfaceCollection<T>
-
isEmpty
public boolean isEmpty()- Specified by:
isEmptyin interfaceCollection<T>
-
size
public int size()- Specified by:
sizein interfaceCollection<T>
-
contains
- Specified by:
containsin interfaceCollection<T>
-
iterator
-
toArray
- Specified by:
toArrayin interfaceCollection<T>
-
toArray
public <E> E[] toArray(E[] a) - Specified by:
toArrayin interfaceCollection<T>
-
remove
- Specified by:
removein interfaceCollection<T>
-
containsAll
- Specified by:
containsAllin interfaceCollection<T>
-
addAll
- Specified by:
addAllin interfaceCollection<T>
-
removeAll
- Specified by:
removeAllin interfaceCollection<T>
-
retainAll
- Specified by:
retainAllin interfaceCollection<T>
-
add
-
remove
-
element
-