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:
java.io.Serializable
,java.lang.Iterable<T>
,java.util.Collection<T>
,java.util.Queue<T>
public final class SpscExactAtomicArrayQueue<T> extends java.util.concurrent.atomic.AtomicReferenceArray<T> implements java.util.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:
- Serialized Form
-
-
Field Summary
Fields Modifier and Type Field Description (package private) int
capacitySkip
(package private) java.util.concurrent.atomic.AtomicLong
consumerIndex
(package private) int
mask
(package private) java.util.concurrent.atomic.AtomicLong
producerIndex
private static long
serialVersionUID
-
Constructor Summary
Constructors Constructor Description SpscExactAtomicArrayQueue(int capacity)
-
Method Summary
All Methods Instance Methods Concrete Methods Modifier and Type Method Description boolean
add(T e)
boolean
addAll(java.util.Collection<? extends T> c)
void
clear()
boolean
contains(java.lang.Object o)
boolean
containsAll(java.util.Collection<?> c)
T
element()
boolean
isEmpty()
java.util.Iterator<T>
iterator()
boolean
offer(T value)
T
peek()
T
poll()
T
remove()
boolean
remove(java.lang.Object o)
boolean
removeAll(java.util.Collection<?> c)
boolean
retainAll(java.util.Collection<?> c)
int
size()
java.lang.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
-
-
-
-
Field Detail
-
serialVersionUID
private static final long serialVersionUID
- See Also:
- Constant Field Values
-
mask
final int mask
-
capacitySkip
final int capacitySkip
-
producerIndex
final java.util.concurrent.atomic.AtomicLong producerIndex
-
consumerIndex
final java.util.concurrent.atomic.AtomicLong consumerIndex
-
-
Method Detail
-
clear
public void clear()
- Specified by:
clear
in interfacejava.util.Collection<T>
-
isEmpty
public boolean isEmpty()
- Specified by:
isEmpty
in interfacejava.util.Collection<T>
-
size
public int size()
- Specified by:
size
in interfacejava.util.Collection<T>
-
contains
public boolean contains(java.lang.Object o)
- Specified by:
contains
in interfacejava.util.Collection<T>
-
iterator
public java.util.Iterator<T> iterator()
-
toArray
public java.lang.Object[] toArray()
- Specified by:
toArray
in interfacejava.util.Collection<T>
-
toArray
public <E> E[] toArray(E[] a)
- Specified by:
toArray
in interfacejava.util.Collection<T>
-
remove
public boolean remove(java.lang.Object o)
- Specified by:
remove
in interfacejava.util.Collection<T>
-
containsAll
public boolean containsAll(java.util.Collection<?> c)
- Specified by:
containsAll
in interfacejava.util.Collection<T>
-
addAll
public boolean addAll(java.util.Collection<? extends T> c)
- Specified by:
addAll
in interfacejava.util.Collection<T>
-
removeAll
public boolean removeAll(java.util.Collection<?> c)
- Specified by:
removeAll
in interfacejava.util.Collection<T>
-
retainAll
public boolean retainAll(java.util.Collection<?> c)
- Specified by:
retainAll
in interfacejava.util.Collection<T>
-
add
public boolean add(T e)
-
-