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

pack-priv abstract Class MpUnboundedXaddArrayQueue<R extends MpUnboundedXaddChunk<R, E>, E>

Additional top-level classes in compilation unit: MpUnboundedXaddArrayQueuePad1, MpUnboundedXaddArrayQueueProducerFields, MpUnboundedXaddArrayQueuePad2, MpUnboundedXaddArrayQueueProducerChunk, MpUnboundedXaddArrayQueuePad3, MpUnboundedXaddArrayQueueConsumerFields, MpUnboundedXaddArrayQueuePad5.

extends MpUnboundedXaddArrayQueuePad5<R extends MpUnboundedXaddChunk<R, E>, 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.MpmcUnboundedXaddArrayQueue, io.netty.util.internal.shaded.org.jctools.queues.MpscUnboundedXaddArrayQueue
Imports
io.netty.util.internal.shaded.org.jctools.queues.IndexedQueueSizeUtil.IndexedQueue, io.netty.util.internal.shaded.org.jctools.util.PortableJvmInfo, .Pow2, .UnsafeAccess, java.util.AbstractQueue, .Iterator

Common infrastructure for the XADD queues.
Author
https://github.com/franz1981

Field Summary

Modifier and TypeField and Description
pack-priv final int
pack-priv final int
pack-priv final SpscArrayQueue<R>
pack-priv final int
private static final long
Inherited from io.netty.util.internal.shaded.org.jctools.queues.MpUnboundedXaddArrayQueuePad5:
b000b001b002b003b004b005b006b007b010b011b012b013b014b015b016b017b020b021b022b023b024b025b026b027b030b031b032b033b034b035b036b037b040b041b042b043b044b045b046b047b050b051b052b053b054b055b056b057b060b061b062b063b064b065b066b067b070b071b072b073b074b075b076b077b100b101b102b103b104b105b106b107b110b111b112b113b114b115b116b117b120b121b122b123b124b125b126b127b130b131b132b133b134b135b136b137b140b141b142b143b144b145b146b147b150b151b152b153b154b155b156b157b160b161b162b163b164b165b166b167

Constructor Summary

AccessConstructor and Description
pack-priv
MpUnboundedXaddArrayQueue(int
The buffer size to be used in each chunk of this queue
chunkSize
,
int
The maximum number of reused chunks kept around to avoid allocation, chunks are pre-allocated
maxPooledChunks
)

Method Summary

Modifier and TypeMethod and Description
private R
appendNextChunks(R currentChunk, long currentChunkIndex, long chunksToAppend)

public int
public final 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 void
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>
iterator()

Implements abstract java.util.AbstractCollection.iterator.

Implements java.util.Collection.iterator.

Returns an iterator over the elements in this collection.
public final int
pack-priv final void
moveToNextConsumerChunk(R cChunk, R next)

Does not null out the first element of `next`, callers must do that

pack-priv abstract R
newChunk(long index, R prev, int chunkSize, boolean pooled)

private R
newOrPooledChunk(R prevChunk, long nextChunkIndex)

pack-priv final R

Returns:

the chunk matching the required index
producerChunkForIndex
(final R
the starting point chunk, which does not match the required chunk index
initialChunk
,
final long
the chunk index we need
requiredChunkIndex
)

We're here because currentChunk.index doesn't match the expectedChunkIndex.

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 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.

Field Detail

chunkMaskback to summary
pack-priv final int chunkMask
chunkShiftback to summary
pack-priv final int chunkShift
freeChunksPoolback to summary
pack-priv final SpscArrayQueue<R> freeChunksPool
maxPooledChunksback to summary
pack-priv final int maxPooledChunks
ROTATIONback to summary
private static final long ROTATION

Constructor Detail

MpUnboundedXaddArrayQueueback to summary
pack-priv MpUnboundedXaddArrayQueue(int chunkSize, int maxPooledChunks)
Parameters
chunkSize:int

The buffer size to be used in each chunk of this queue

maxPooledChunks:int

The maximum number of reused chunks kept around to avoid allocation, chunks are pre-allocated

Method Detail

appendNextChunksback to summary
private R appendNextChunks(R currentChunk, long currentChunkIndex, long chunksToAppend)
capacityback to summary
public int capacity()

Implements 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
chunkSizeback to summary
public final int chunkSize()
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 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
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.

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
maxPooledChunksback to summary
public final int maxPooledChunks()
moveToNextConsumerChunkback to summary
pack-priv final void moveToNextConsumerChunk(R cChunk, R next)

Does not null out the first element of `next`, callers must do that

newChunkback to summary
pack-priv abstract R newChunk(long index, R prev, int chunkSize, boolean pooled)
newOrPooledChunkback to summary
private R newOrPooledChunk(R prevChunk, long nextChunkIndex)
producerChunkForIndexback to summary
pack-priv final R producerChunkForIndex(final R initialChunk, final long requiredChunkIndex)

We're here because currentChunk.index doesn't match the expectedChunkIndex. To resolve we must now chase the linked chunks to the appropriate chunk. More than one producer may end up racing to add or discover new chunks.

Parameters
initialChunk:R

the starting point chunk, which does not match the required chunk index

requiredChunkIndex:long

the chunk index we need

Returns:R

the chunk matching the required index

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
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