Top Description Inners Fields Constructors Methods
io.netty.util.internal.shaded.org.jctools.queues.atomic

pack-priv abstract Class BaseMpscLinkedAtomicArrayQueue<E>

Additional top-level classes in compilation unit: BaseMpscLinkedAtomicArrayQueuePad1, BaseMpscLinkedAtomicArrayQueueProducerFields, BaseMpscLinkedAtomicArrayQueuePad2, BaseMpscLinkedAtomicArrayQueueConsumerFields, BaseMpscLinkedAtomicArrayQueuePad3, BaseMpscLinkedAtomicArrayQueueColdProducerFields.

extends BaseMpscLinkedAtomicArrayQueueColdProducerFields<E>
implements MessagePassingQueue<E>, QueueProgressIndicators
Class Inheritance
All Implemented Interfaces
io.netty.util.internal.shaded.org.jctools.queues.QueueProgressIndicators, io.netty.util.internal.shaded.org.jctools.queues.MessagePassingQueue
Known Direct Subclasses
io.netty.util.internal.shaded.org.jctools.queues.atomic.MpscChunkedAtomicArrayQueueColdProducerFields, io.netty.util.internal.shaded.org.jctools.queues.atomic.MpscUnboundedAtomicArrayQueue
Imports
io.netty.util.internal.shaded.org.jctools.queues.IndexedQueueSizeUtil.IndexedQueue, .MessagePassingQueue, .MessagePassingQueue.Supplier, .MessagePassingQueueUtil, .QueueProgressIndicators, .IndexedQueueSizeUtil, io.netty.util.internal.shaded.org.jctools.util.PortableJvmInfo, .Pow2, .RangeUtil, java.util.AbstractQueue, .Iterator, .NoSuchElementException, java.util.concurrent.atomic.AtomicReferenceFieldUpdater, .AtomicLongFieldUpdater, .AtomicReferenceArray

Note

This class was automatically generated by io.netty.util.internal.shaded.org.jctools.queues.atomic.JavaParsingAtomicLinkedQueueGenerator which can found in the jctools-build module. The original source file is BaseMpscLinkedArrayQueue.java. An MPSC array queue which starts at initialCapacity and grows to maxCapacity in linked chunks of the initial size. The queue grows only when the current buffer is full and elements are not copied on resize, instead a link to the new buffer is stored in the old buffer for the consumer to follow.

Nested and Inner Type Summary

Modifier and TypeClass and Description
private static class
BaseMpscLinkedAtomicArrayQueue.WeakIterator<E>

Note

This class was automatically generated by io.netty.util.internal.shaded.org.jctools.queues.atomic.JavaParsingAtomicLinkedQueueGenerator which can found in the jctools-build module.

Field Summary

Modifier and TypeField and Description
private static final Object
private static final int
private static final Object
private static final int
private static final int
private static final int
Inherited from io.netty.util.internal.shaded.org.jctools.queues.atomic.BaseMpscLinkedAtomicArrayQueueColdProducerFields:
producerBufferproducerMask

Constructor Summary

AccessConstructor and Description
public
BaseMpscLinkedAtomicArrayQueue(final int
the queue initial capacity. If chunk size is fixed this will be the chunk size. Must be 2 or more.
initialCapacity
)

Method Summary

Modifier and TypeMethod and Description
protected abstract long

Returns:

available elements in queue * 2
availableInQueue
(long pIndex, long cIndex)

public abstract int
public long
public long
public int
drain(MessagePassingQueue.Consumer<E> c)

Implements io.netty.util.internal.shaded.org.jctools.queues.MessagePassingQueue.drain.

Remove all available item from the queue and hand to consume.
public int
drain(MessagePassingQueue.Consumer<E> c, int limit)

Implements io.netty.util.internal.shaded.org.jctools.queues.MessagePassingQueue.drain.

Remove up to limit elements from the queue and hand to consume.
public void
public int
fill(MessagePassingQueue.Supplier<E> s)

Implements io.netty.util.internal.shaded.org.jctools.queues.MessagePassingQueue.fill.

Stuff the queue with elements from the supplier.
public int
fill(MessagePassingQueue.Supplier<E> s, int limit)

Implements io.netty.util.internal.shaded.org.jctools.queues.MessagePassingQueue.fill.

Stuff the queue with up to limit elements from the supplier.
public void
protected abstract long

Returns:

current buffer capacity for elements (excluding next pointer and jump entry) * 2
getCurrentBufferCapacity
(long mask)

protected abstract int

Returns:

next buffer size(inclusive of next array pointer)
getNextBufferSize
(AtomicReferenceArray<E> buffer)

public boolean
isEmpty()

Overrides java.util.AbstractCollection.isEmpty.

Implements io.netty.util.internal.shaded.org.jctools.queues.MessagePassingQueue.isEmpty, java.util.Collection.isEmpty.

This method's accuracy is subject to concurrent modifications happening as the observation is carried out.
public Iterator<E>

Returns:

The iterator.
iterator
()

Implements abstract java.util.AbstractCollection.iterator.

Implements java.util.Collection.iterator.

Get an iterator for this queue.
private E
newBufferPeek(AtomicReferenceArray<E> nextBuffer, long index)

private E
newBufferPoll(AtomicReferenceArray<E> nextBuffer, long index)

private static int
nextArrayOffset(long mask)

private AtomicReferenceArray<E>
nextBuffer(final AtomicReferenceArray<E> buffer, final long mask)

public boolean
offer(final E
not null, will throw NPE if it is
e
)

Implements io.netty.util.internal.shaded.org.jctools.queues.MessagePassingQueue.offer, java.util.Queue.offer.

Called from a producer thread subject to the restrictions appropriate to the implementation and according to the Queue#offer(Object) interface.
private int
offerSlowPath(long mask, long pIndex, long producerLimit)

We do not inline resize into this method because we do not resize on fill.

public E
peek()

Implements io.netty.util.internal.shaded.org.jctools.queues.MessagePassingQueue.peek, java.util.Queue.peek.

Called from the consumer thread subject to the restrictions appropriate to the implementation and according to the Queue#peek() interface.
public E
poll()

Implements io.netty.util.internal.shaded.org.jctools.queues.MessagePassingQueue.poll, java.util.Queue.poll.

Called from the consumer thread subject to the restrictions appropriate to the implementation and according to the Queue#poll() interface.
public boolean
relaxedOffer(E
not null, will throw NPE if it is
e
)

Implements io.netty.util.internal.shaded.org.jctools.queues.MessagePassingQueue.relaxedOffer.

Called from a producer thread subject to the restrictions appropriate to the implementation.
public E
relaxedPeek()

Implements io.netty.util.internal.shaded.org.jctools.queues.MessagePassingQueue.relaxedPeek.

Called from the consumer thread subject to the restrictions appropriate to the implementation.
public E
relaxedPoll()

Implements io.netty.util.internal.shaded.org.jctools.queues.MessagePassingQueue.relaxedPoll.

Called from the consumer thread subject to the restrictions appropriate to the implementation.
private void
resize(long oldMask, AtomicReferenceArray<E> oldBuffer, long pIndex, E e, MessagePassingQueue.Supplier<E> s)

public int
size()

Implements abstract java.util.AbstractCollection.size.

Implements io.netty.util.internal.shaded.org.jctools.queues.MessagePassingQueue.size, java.util.Collection.size.

This method's accuracy is subject to concurrent modifications happening as the size is estimated and as such is a best effort rather than absolute value.
public String
toString()

Overrides java.util.AbstractCollection.toString.

Returns a string representation of this collection.
Inherited from io.netty.util.internal.shaded.org.jctools.queues.atomic.BaseMpscLinkedAtomicArrayQueueColdProducerFields:
casProducerLimitlvProducerLimitsoProducerLimit

Field Detail

BUFFER_CONSUMEDback to summary
private static final Object BUFFER_CONSUMED
CONTINUE_TO_P_INDEX_CASback to summary
private static final int CONTINUE_TO_P_INDEX_CAS
JUMPback to summary
private static final Object JUMP
QUEUE_FULLback to summary
private static final int QUEUE_FULL
QUEUE_RESIZEback to summary
private static final int QUEUE_RESIZE
RETRYback to summary
private static final int RETRY

Constructor Detail

BaseMpscLinkedAtomicArrayQueueback to summary
public BaseMpscLinkedAtomicArrayQueue(final int initialCapacity)
Parameters
initialCapacity:int

the queue initial capacity. If chunk size is fixed this will be the chunk size. Must be 2 or more.

Method Detail

availableInQueueback to summary
protected abstract long availableInQueue(long pIndex, long cIndex)
Returns:long

available elements in queue * 2

capacityback to summary
public abstract int capacity()

Redeclares io.netty.util.internal.shaded.org.jctools.queues.MessagePassingQueue.capacity, io.netty.util.internal.shaded.org.jctools.queues.IndexedQueueSizeUtil.IndexedQueue.capacity.

Returns:int

Doc from io.netty.util.internal.shaded.org.jctools.queues.MessagePassingQueue.capacity.

the capacity of this queue or MessagePassingQueue#UNBOUNDED_CAPACITY if not bounded

Annotations
@Override
currentConsumerIndexback to summary
public long currentConsumerIndex()

Implements io.netty.util.internal.shaded.org.jctools.queues.QueueProgressIndicators.currentConsumerIndex.

Doc from io.netty.util.internal.shaded.org.jctools.queues.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 io.netty.util.internal.shaded.org.jctools.queues.QueueProgressIndicators.currentProducerIndex.

Doc from io.netty.util.internal.shaded.org.jctools.queues.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
drainback to summary
public int drain(MessagePassingQueue.Consumer<E> c)

Implements io.netty.util.internal.shaded.org.jctools.queues.MessagePassingQueue.drain.

Doc from io.netty.util.internal.shaded.org.jctools.queues.MessagePassingQueue.drain.

Remove all available item from the queue and hand to consume. This should be semantically similar to:

M m;
while((m = relaxedPoll()) != null){
c.accept(m);
}
There's no strong commitment to the queue being empty at the end of a drain. Called from a consumer thread subject to the restrictions appropriate to the implementation.

Warning

Explicit assumptions are made with regards to Consumer#accept make sure you have read and understood these before using this method.

Returns:int

the number of polled elements

Annotations
@Override
drainback to summary
public int drain(MessagePassingQueue.Consumer<E> c, int limit)

Implements io.netty.util.internal.shaded.org.jctools.queues.MessagePassingQueue.drain.

Doc from io.netty.util.internal.shaded.org.jctools.queues.MessagePassingQueue.drain.

Remove up to limit elements from the queue and hand to consume. This should be semantically similar to:

M m;
  int i = 0;
  for(;i < limit && (m = relaxedPoll()) != null; i++){
    c.accept(m);
  }
  return i;

There's no strong commitment to the queue being empty at the end of a drain. Called from a consumer thread subject to the restrictions appropriate to the implementation.

Warning

Explicit assumptions are made with regards to Consumer#accept make sure you have read and understood these before using this method.

Returns:int

the number of polled elements

Annotations
@Override
drainback to summary
public void drain(MessagePassingQueue.Consumer<E> c, MessagePassingQueue.WaitStrategy wait, MessagePassingQueue.ExitCondition exit)

Implements io.netty.util.internal.shaded.org.jctools.queues.MessagePassingQueue.drain.

Doc from io.netty.util.internal.shaded.org.jctools.queues.MessagePassingQueue.drain.

Remove elements from the queue and hand to consume forever. Semantically similar to:

 int idleCounter = 0;
 while (exit.keepRunning()) {
     E e = relaxedPoll();
     if(e==null){
         idleCounter = wait.idle(idleCounter);
         continue;
     }
     idleCounter = 0;
     c.accept(e);
 }

Called from a consumer thread subject to the restrictions appropriate to the implementation.

Warning

Explicit assumptions are made with regards to Consumer#accept make sure you have read and understood these before using this method.

Annotations
@Override
fillback to summary
public int fill(MessagePassingQueue.Supplier<E> s)

Implements io.netty.util.internal.shaded.org.jctools.queues.MessagePassingQueue.fill.

Doc from io.netty.util.internal.shaded.org.jctools.queues.MessagePassingQueue.fill.

Stuff the queue with elements from the supplier. Semantically similar to:

while(relaxedOffer(s.get());
There's no strong commitment to the queue being full at the end of a fill. Called from a producer thread subject to the restrictions appropriate to the implementation.

Unbounded queues will fill up the queue with a fixed amount rather than fill up to oblivion

Warning

Explicit assumptions are made with regards to Supplier#get make sure you have read and understood these before using this method.

Returns:int

the number of offered elements

Annotations
@Override
fillback to summary
public int fill(MessagePassingQueue.Supplier<E> s, int limit)

Implements io.netty.util.internal.shaded.org.jctools.queues.MessagePassingQueue.fill.

Doc from io.netty.util.internal.shaded.org.jctools.queues.MessagePassingQueue.fill.

Stuff the queue with up to limit elements from the supplier. Semantically similar to:

for(int i=0; i < limit && relaxedOffer(s.get()); i++);

There's no strong commitment to the queue being full at the end of a fill. Called from a producer thread subject to the restrictions appropriate to the implementation

Warning

Explicit assumptions are made with regards to Supplier#get make sure you have read and understood these before using this method.

Returns:int

the number of offered elements

Annotations
@Override
fillback to summary
public void fill(MessagePassingQueue.Supplier<E> s, MessagePassingQueue.WaitStrategy wait, MessagePassingQueue.ExitCondition exit)

Implements io.netty.util.internal.shaded.org.jctools.queues.MessagePassingQueue.fill.

Doc from io.netty.util.internal.shaded.org.jctools.queues.MessagePassingQueue.fill.

Stuff the queue with elements from the supplier forever. Semantically similar to:


 int idleCounter = 0;
 while (exit.keepRunning()) {
     E e = s.get();
     while (!relaxedOffer(e)) {
         idleCounter = wait.idle(idleCounter);
         continue;
     }
     idleCounter = 0;
 }

Called from a producer thread subject to the restrictions appropriate to the implementation. The main difference being that implementors MUST assure room in the queue is available BEFORE calling Supplier#get

Warning

Explicit assumptions are made with regards to Supplier#get make sure you have read and understood these before using this method.

Annotations
@Override
getCurrentBufferCapacityback to summary
protected abstract long getCurrentBufferCapacity(long mask)
Returns:long

current buffer capacity for elements (excluding next pointer and jump entry) * 2

getNextBufferSizeback to summary
protected abstract int getNextBufferSize(AtomicReferenceArray<E> buffer)
Returns:int

next buffer size(inclusive of next array pointer)

isEmptyback to summary
public boolean isEmpty()

Overrides java.util.AbstractCollection.isEmpty.

Implements io.netty.util.internal.shaded.org.jctools.queues.MessagePassingQueue.isEmpty, java.util.Collection.isEmpty.

Doc from io.netty.util.internal.shaded.org.jctools.queues.MessagePassingQueue.isEmpty.

This method's accuracy is subject to concurrent modifications happening as the observation is carried out.

Returns:boolean

true if empty, false otherwise

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

Implements abstract java.util.AbstractCollection.iterator.

Implements java.util.Collection.iterator.

Get an iterator for this queue. This method is thread safe.

The iterator provides a best-effort snapshot of the elements in the queue. The returned iterator is not guaranteed to return elements in queue order, and races with the consumer thread may cause gaps in the sequence of returned elements. Like {link #relaxedPoll}, the iterator may not immediately return newly inserted elements.

Returns:Iterator<E>

The iterator.

Annotations
@Override
newBufferPeekback to summary
private E newBufferPeek(AtomicReferenceArray<E> nextBuffer, long index)
newBufferPollback to summary
private E newBufferPoll(AtomicReferenceArray<E> nextBuffer, long index)
nextArrayOffsetback to summary
private static int nextArrayOffset(long mask)
nextBufferback to summary
private AtomicReferenceArray<E> nextBuffer(final AtomicReferenceArray<E> buffer, final long mask)
Annotations
@SuppressWarnings:unchecked
offerback to summary
public boolean offer(final E e)

Implements io.netty.util.internal.shaded.org.jctools.queues.MessagePassingQueue.offer, java.util.Queue.offer.

Doc from io.netty.util.internal.shaded.org.jctools.queues.MessagePassingQueue.offer.

Called from a producer thread subject to the restrictions appropriate to the implementation and according to the Queue#offer(Object) interface.

Parameters
e:E

not null, will throw NPE if it is

Returns:boolean

true if element was inserted into the queue, false iff full

Annotations
@Override
offerSlowPathback to summary
private int offerSlowPath(long mask, long pIndex, long producerLimit)

We do not inline resize into this method because we do not resize on fill.

peekback to summary
public E peek()

Implements io.netty.util.internal.shaded.org.jctools.queues.MessagePassingQueue.peek, java.util.Queue.peek.

Doc from io.netty.util.internal.shaded.org.jctools.queues.MessagePassingQueue.peek.

Called from the consumer thread subject to the restrictions appropriate to the implementation and according to the Queue#peek() interface.

This implementation is correct for single consumer thread use only.

Returns:E

a message from the queue if one is available, null iff empty

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

Implements io.netty.util.internal.shaded.org.jctools.queues.MessagePassingQueue.poll, java.util.Queue.poll.

Doc from io.netty.util.internal.shaded.org.jctools.queues.MessagePassingQueue.poll.

Called from the consumer thread subject to the restrictions appropriate to the implementation and according to the Queue#poll() interface.

This implementation is correct for single consumer thread use only.

Returns:E

a message from the queue if one is available, null iff empty

Annotations
@SuppressWarnings:unchecked
@Override
relaxedOfferback to summary
public boolean relaxedOffer(E e)

Implements io.netty.util.internal.shaded.org.jctools.queues.MessagePassingQueue.relaxedOffer.

Doc from io.netty.util.internal.shaded.org.jctools.queues.MessagePassingQueue.relaxedOffer.

Called from a producer thread subject to the restrictions appropriate to the implementation. As opposed to Queue#offer(Object) this method may return false without the queue being full.

Parameters
e:E

not null, will throw NPE if it is

Returns:boolean

true if element was inserted into the queue, false if unable to offer

Annotations
@Override
relaxedPeekback to summary
public E relaxedPeek()

Implements io.netty.util.internal.shaded.org.jctools.queues.MessagePassingQueue.relaxedPeek.

Doc from io.netty.util.internal.shaded.org.jctools.queues.MessagePassingQueue.relaxedPeek.

Called from the consumer thread subject to the restrictions appropriate to the implementation. As opposed to Queue#peek() this method may return null without the queue being empty.

Returns:E

a message from the queue if one is available, null if unable to peek

Annotations
@SuppressWarnings:unchecked
@Override
relaxedPollback to summary
public E relaxedPoll()

Implements io.netty.util.internal.shaded.org.jctools.queues.MessagePassingQueue.relaxedPoll.

Doc from io.netty.util.internal.shaded.org.jctools.queues.MessagePassingQueue.relaxedPoll.

Called from the consumer thread subject to the restrictions appropriate to the implementation. As opposed to Queue#poll() this method may return null without the queue being empty.

Returns:E

a message from the queue if one is available, null if unable to poll

Annotations
@SuppressWarnings:unchecked
@Override
resizeback to summary
private void resize(long oldMask, AtomicReferenceArray<E> oldBuffer, long pIndex, E e, MessagePassingQueue.Supplier<E> s)
sizeback to summary
public int size()

Implements abstract java.util.AbstractCollection.size.

Implements io.netty.util.internal.shaded.org.jctools.queues.MessagePassingQueue.size, java.util.Collection.size.

Doc from io.netty.util.internal.shaded.org.jctools.queues.MessagePassingQueue.size.

This method's accuracy is subject to concurrent modifications happening as the size is estimated and as such is a best effort rather than absolute value. For some implementations this method may be O(n) rather than O(1).

Returns:int

number of messages in the queue, between 0 and Integer#MAX_VALUE but less or equals to capacity (if bounded).

Annotations
@Override
toStringback to summary
public String toString()

Overrides java.util.AbstractCollection.toString.

Doc from java.util.AbstractCollection.toString.

Returns a string representation of this collection. The string representation consists of a list of the collection's elements in the order they are returned by its iterator, enclosed in square brackets ("[]"). Adjacent elements are separated by the characters ", " (comma and space). Elements are converted to strings as by String#valueOf(Object).

Returns:String

a string representation of this collection

Annotations
@Override
io.netty.util.internal.shaded.org.jctools.queues.atomic back to summary

private Class BaseMpscLinkedAtomicArrayQueue.WeakIterator<E>

extends Object
implements Iterator<E>
Class Inheritance
  • java.lang.Object
  • io.netty.util.internal.shaded.org.jctools.queues.atomic.BaseMpscLinkedAtomicArrayQueue.WeakIterator
All Implemented Interfaces
java.util.Iterator

Note

This class was automatically generated by io.netty.util.internal.shaded.org.jctools.queues.atomic.JavaParsingAtomicLinkedQueueGenerator which can found in the jctools-build module. The original source file is BaseMpscLinkedArrayQueue.java.

Field Summary

Modifier and TypeField and Description
private AtomicReferenceArray<E>
private int
private E
private long
private final long

Constructor Summary

AccessConstructor and Description
pack-priv
WeakIterator(AtomicReferenceArray<E> currentBuffer, long cIndex, long pIndex)

Method Summary

Modifier and TypeMethod and Description
private E
public boolean
hasNext()

Implements java.util.Iterator.hasNext.

Returns true if the iteration has more elements.
public E
next()

Implements java.util.Iterator.next.

Returns the next element in the iteration.
public void
remove()

Overrides default java.util.Iterator.remove.

Removes from the underlying collection the last element returned by this iterator (optional operation).
private void
Inherited from java.lang.Object:
cloneequalsfinalizegetClasshashCodenotifynotifyAlltoStringwaitwaitwait

Field Detail

currentBufferback to summary
private AtomicReferenceArray<E> currentBuffer
maskback to summary
private int mask
nextElementback to summary
private E nextElement
nextIndexback to summary
private long nextIndex
pIndexback to summary
private final long pIndex

Constructor Detail

WeakIteratorback to summary
pack-priv WeakIterator(AtomicReferenceArray<E> currentBuffer, long cIndex, long pIndex)

Method Detail

getNextback to summary
private E getNext()
hasNextback to summary
public boolean hasNext()

Implements java.util.Iterator.hasNext.

Doc from java.util.Iterator.hasNext.

Returns true if the iteration has more elements. (In other words, returns true if next would return an element rather than throwing an exception.)

Returns:boolean

true if the iteration has more elements

Annotations
@Override
nextback to summary
public E next()

Implements java.util.Iterator.next.

Doc from java.util.Iterator.next.

Returns the next element in the iteration.

Returns:E

the next element in the iteration

Annotations
@Override
removeback to summary
public void remove()

Overrides default java.util.Iterator.remove.

Doc from java.util.Iterator.remove.

Removes from the underlying collection the last element returned by this iterator (optional operation). This method can be called only once per call to next.

The behavior of an iterator is unspecified if the underlying collection is modified while the iteration is in progress in any way other than by calling this method, unless an overriding class has specified a concurrent modification policy.

The behavior of an iterator is unspecified if this method is called after a call to the forEachRemaining method.

Annotations
@Override
setBufferback to summary
private void setBuffer(AtomicReferenceArray<E> buffer)