Top Fields Constructors Methods
rx.internal.util.unsafe

public Class SpscUnboundedArrayQueue<E>

Additional top-level classes in compilation unit: SpscUnboundedArrayQueueProducerFields, SpscUnboundedArrayQueueProducerColdFields, SpscUnboundedArrayQueueL2Pad, SpscUnboundedArrayQueueConsumerColdField, SpscUnboundedArrayQueueConsumerField.

extends SpscUnboundedArrayQueueConsumerField<E>
implements QueueProgressIndicators
Class Inheritance
All Implemented Interfaces
rx.internal.util.unsafe.QueueProgressIndicators
Annotations
@SuppressAnimalSniffer
Static Imports
rx.internal.util.unsafe.UnsafeAccess.*

Field Summary

Modifier and TypeField and Description
private static final long
private static final Object
pack-priv static final int
private static final long
private static final long
private static final int
Inherited from rx.internal.util.unsafe.SpscUnboundedArrayQueueConsumerField:
consumerIndex

Constructor Summary

AccessConstructor and Description
public
SpscUnboundedArrayQueue(final int bufferSize)

Method Summary

Modifier and TypeMethod and Description
private void
adjustLookAheadStep(int capacity)

private static long
calcDirectOffset(long index)

private static long
calcWrappedOffset(long index, long mask)

public long
currentConsumerIndex()

Implements rx.internal.util.unsafe.QueueProgressIndicators.currentConsumerIndex.

This method has no concurrent visibility semantics.
public long
currentProducerIndex()

Implements rx.internal.util.unsafe.QueueProgressIndicators.currentProducerIndex.

This method has no concurrent visibility semantics.
public final Iterator<E>
iterator()

Implements abstract java.util.AbstractCollection.iterator.

Implements java.util.Collection.iterator.

Returns an iterator over the elements in this collection.
private long
private static <E> Object
lvElement(E[] buffer, long offset)

private E[]
lvNext(E[] curr)

private long
private E
newBufferPeek(E[] nextBuffer, final long index, final long mask)

private E
newBufferPoll(E[] nextBuffer, final long index, final long mask)

public final boolean
offer(final E
the element to add
e
)

Implements java.util.Queue.offer.

Inserts the specified element into this queue if it is possible to do so immediately without violating capacity restrictions.
public final E
peek()

Implements java.util.Queue.peek.

Retrieves, but does not remove, the head of this queue, or returns null if this queue is empty.
public final E
poll()

Implements java.util.Queue.poll.

Retrieves and removes the head of this queue, or returns null if this queue is empty.
private void
resize(final E[] oldBuffer, final long currIndex, final long offset, final E e, final long mask)

public final int
size()

Implements abstract java.util.AbstractCollection.size.

Implements java.util.Collection.size.

Returns the number of elements in this collection.
private void
private static void
soElement(Object[] buffer, long offset, Object e)

private void
soNext(E[] curr, E[] next)

private void
private boolean
writeToQueue(final E[] buffer, final E e, final long index, final long offset)

Field Detail

C_INDEX_OFFSETback to summary
private static final long C_INDEX_OFFSET
HAS_NEXTback to summary
private static final Object HAS_NEXT
MAX_LOOK_AHEAD_STEPback to summary
pack-priv static final int MAX_LOOK_AHEAD_STEP
P_INDEX_OFFSETback to summary
private static final long P_INDEX_OFFSET
REF_ARRAY_BASEback to summary
private static final long REF_ARRAY_BASE
REF_ELEMENT_SHIFTback to summary
private static final int REF_ELEMENT_SHIFT

Constructor Detail

SpscUnboundedArrayQueueback to summary
public SpscUnboundedArrayQueue(final int bufferSize)
Annotations
@SuppressWarnings:unchecked

Method Detail

adjustLookAheadStepback to summary
private void adjustLookAheadStep(int capacity)
calcDirectOffsetback to summary
private static long calcDirectOffset(long index)
calcWrappedOffsetback to summary
private static long calcWrappedOffset(long index, long mask)
currentConsumerIndexback to summary
public long currentConsumerIndex()

Implements rx.internal.util.unsafe.QueueProgressIndicators.currentConsumerIndex.

Doc from rx.internal.util.unsafe.QueueProgressIndicators.currentConsumerIndex.

This method has no concurrent visibility semantics. The value returned may be negative. Under normal circumstances 2 consecutive calls to this method can offer an idea of progress made by consumer threads by subtracting the 2 results though in extreme cases (if consumers have progressed by more than 2^64) this may also fail.
This value will normally indicate number of elements taken out of the queue, but may under some circumstances be a derivative of that figure. This method should not be used to derive size or emptiness.

Returns:long

the current value of the consumer progress index

Annotations
@Override
currentProducerIndexback to summary
public long currentProducerIndex()

Implements rx.internal.util.unsafe.QueueProgressIndicators.currentProducerIndex.

Doc from rx.internal.util.unsafe.QueueProgressIndicators.currentProducerIndex.

This method has no concurrent visibility semantics. The value returned may be negative. Under normal circumstances 2 consecutive calls to this method can offer an idea of progress made by producer threads by subtracting the 2 results though in extreme cases (if producers have progressed by more than 2^64) this may also fail.
This value will normally indicate number of elements passed into the queue, but may under some circumstances be a derivative of that figure. This method should not be used to derive size or emptiness.

Returns:long

the current value of the producer progress index

Annotations
@Override
iteratorback to summary
public final Iterator<E> iterator()

Implements abstract java.util.AbstractCollection.iterator.

Implements java.util.Collection.iterator.

Doc from java.util.Collection.iterator.

Returns an iterator over the elements in this collection. There are no guarantees concerning the order in which the elements are returned (unless this collection is an instance of some class that provides a guarantee).

Returns:Iterator<E>

an Iterator over the elements in this collection

Annotations
@Override
lvConsumerIndexback to summary
private long lvConsumerIndex()
lvElementback to summary
private static <E> Object lvElement(E[] buffer, long offset)
lvNextback to summary
private E[] lvNext(E[] curr)
Annotations
@SuppressWarnings:unchecked
lvProducerIndexback to summary
private long lvProducerIndex()
newBufferPeekback to summary
private E newBufferPeek(E[] nextBuffer, final long index, final long mask)
Annotations
@SuppressWarnings:unchecked
newBufferPollback to summary
private E newBufferPoll(E[] nextBuffer, final long index, final long mask)
Annotations
@SuppressWarnings:unchecked
offerback to summary
public final boolean offer(final E e)

Implements java.util.Queue.offer.

Doc from java.util.Queue.offer.

Inserts the specified element into this queue if it is possible to do so immediately without violating capacity restrictions. When using a capacity-restricted queue, this method is generally preferable to add, which can fail to insert an element only by throwing an exception.

This implementation is correct for single producer thread use only.

Parameters
e:E

the element to add

Returns:boolean

true if the element was added to this queue, else false

Annotations
@Override
peekback to summary
public final E peek()

Implements java.util.Queue.peek.

Doc from java.util.Queue.peek.

Retrieves, but does not remove, the head of this queue, or returns null if this queue is empty.

This implementation is correct for single consumer thread use only.

Returns:E

the head of this queue, or null if this queue is empty

Annotations
@SuppressWarnings:unchecked
@Override
pollback to summary
public final E poll()

Implements java.util.Queue.poll.

Doc from java.util.Queue.poll.

Retrieves and removes the head of this queue, or returns null if this queue is empty.

This implementation is correct for single consumer thread use only.

Returns:E

the head of this queue, or null if this queue is empty

Annotations
@SuppressWarnings:unchecked
@Override
resizeback to summary
private void resize(final E[] oldBuffer, final long currIndex, final long offset, final E e, final long mask)
Annotations
@SuppressWarnings:unchecked
sizeback to summary
public final int size()

Implements abstract java.util.AbstractCollection.size.

Implements java.util.Collection.size.

Doc from java.util.Collection.size.

Returns the number of elements in this collection. If this collection contains more than Integer.MAX_VALUE elements, returns Integer.MAX_VALUE.

Returns:int

the number of elements in this collection

Annotations
@Override
soConsumerIndexback to summary
private void soConsumerIndex(long v)
soElementback to summary
private static void soElement(Object[] buffer, long offset, Object e)
soNextback to summary
private void soNext(E[] curr, E[] next)
soProducerIndexback to summary
private void soProducerIndex(long v)
writeToQueueback to summary
private boolean writeToQueue(final E[] buffer, final E e, final long index, final long offset)