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 AtomicLong
private static final long
-
Constructor Summary
Constructors -
Method Summary
Modifier and TypeMethodDescriptionboolean
boolean
addAll
(Collection<? extends T> c) void
clear()
boolean
boolean
containsAll
(Collection<?> c) element()
boolean
isEmpty()
iterator()
boolean
peek()
poll()
remove()
boolean
boolean
removeAll
(Collection<?> c) boolean
retainAll
(Collection<?> c) int
size()
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, weakCompareAndSetVolatile
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, wait, wait, wait
Methods 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:
clear
in interfaceCollection<T>
-
isEmpty
public boolean isEmpty()- Specified by:
isEmpty
in interfaceCollection<T>
-
size
public int size()- Specified by:
size
in interfaceCollection<T>
-
contains
- Specified by:
contains
in interfaceCollection<T>
-
iterator
-
toArray
- Specified by:
toArray
in interfaceCollection<T>
-
toArray
public <E> E[] toArray(E[] a) - Specified by:
toArray
in interfaceCollection<T>
-
remove
- Specified by:
remove
in interfaceCollection<T>
-
containsAll
- Specified by:
containsAll
in interfaceCollection<T>
-
addAll
- Specified by:
addAll
in interfaceCollection<T>
-
removeAll
- Specified by:
removeAll
in interfaceCollection<T>
-
retainAll
- Specified by:
retainAll
in interfaceCollection<T>
-
add
-
remove
-
element
-