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

public Class MpscBlockingConsumerArrayQueue<E>

Additional top-level classes in compilation unit: MpscBlockingConsumerArrayQueuePad1, MpscBlockingConsumerArrayQueueColdProducerFields, MpscBlockingConsumerArrayQueuePad2, MpscBlockingConsumerArrayQueueProducerFields, MpscBlockingConsumerArrayQueuePad3, MpscBlockingConsumerArrayQueueConsumerFields.

extends MpscBlockingConsumerArrayQueueConsumerFields<E>
implements MessagePassingQueue<E>, QueueProgressIndicators, BlockingQueue<E>
Class Inheritance
All Implemented Interfaces
java.util.concurrent.BlockingQueue, java.util.Queue, java.util.Collection, java.lang.Iterable, io.netty.util.internal.shaded.org.jctools.queues.QueueProgressIndicators, io.netty.util.internal.shaded.org.jctools.queues.MessagePassingQueue
Annotations
@SuppressWarnings:unused
Imports
java.util.AbstractQueue, .Collection, .Iterator, java.util.concurrent.BlockingQueue, .TimeUnit, java.util.concurrent.locks.LockSupport, io.netty.util.internal.shaded.org.jctools.queues.IndexedQueueSizeUtil.IndexedQueue, io.netty.util.internal.shaded.org.jctools.util.Pow2, .RangeUtil

This is a partial implementation of the java.util.concurrent.BlockingQueue on the consumer side only on top of the mechanics described in BaseMpscLinkedArrayQueue, but with the reservation bit used for blocking rather than resizing in this instance.

Field Summary

Modifier and TypeField and Description
pack-priv byte
pack-priv byte
pack-priv byte
pack-priv byte
pack-priv byte
pack-priv byte
pack-priv byte
pack-priv byte
pack-priv byte
pack-priv byte
pack-priv byte
pack-priv byte
pack-priv byte
pack-priv byte
pack-priv byte
pack-priv byte
pack-priv byte
pack-priv byte
pack-priv byte
pack-priv byte
pack-priv byte
pack-priv byte
pack-priv byte
pack-priv byte
pack-priv byte
pack-priv byte
pack-priv byte
pack-priv byte
pack-priv byte
pack-priv byte
pack-priv byte
pack-priv byte
pack-priv byte
pack-priv byte
pack-priv byte
pack-priv byte
pack-priv byte
pack-priv byte
pack-priv byte
pack-priv byte
pack-priv byte
pack-priv byte
pack-priv byte
pack-priv byte
pack-priv byte
pack-priv byte
pack-priv byte
pack-priv byte
pack-priv byte
pack-priv byte
pack-priv byte
pack-priv byte
pack-priv byte
pack-priv byte
pack-priv byte
pack-priv byte
pack-priv byte
pack-priv byte
pack-priv byte
pack-priv byte
pack-priv byte
pack-priv byte
pack-priv byte
pack-priv byte
pack-priv byte
pack-priv byte
pack-priv byte
pack-priv byte
pack-priv byte
pack-priv byte
pack-priv byte
pack-priv byte
pack-priv byte
pack-priv byte
pack-priv byte
pack-priv byte
pack-priv byte
pack-priv byte
pack-priv byte
pack-priv byte
pack-priv byte
pack-priv byte
pack-priv byte
pack-priv byte
pack-priv byte
pack-priv byte
pack-priv byte
pack-priv byte
pack-priv byte
pack-priv byte
pack-priv byte
pack-priv byte
pack-priv byte
pack-priv byte
pack-priv byte
pack-priv byte
pack-priv byte
pack-priv byte
pack-priv byte
pack-priv byte
pack-priv byte
pack-priv byte
pack-priv byte
pack-priv byte
pack-priv byte
pack-priv byte
pack-priv byte
pack-priv byte
pack-priv byte
pack-priv byte
pack-priv byte
pack-priv byte
pack-priv byte
pack-priv byte
pack-priv byte
pack-priv byte
pack-priv byte
pack-priv byte
pack-priv byte
pack-priv byte
pack-priv byte
pack-priv byte
pack-priv byte
pack-priv byte
pack-priv byte
pack-priv byte
pack-priv byte
pack-priv byte
Inherited from io.netty.util.internal.shaded.org.jctools.queues.MpscBlockingConsumerArrayQueueConsumerFields:
consumerBufferconsumerMask

Constructor Summary

AccessConstructor and Description
public
MpscBlockingConsumerArrayQueue(final int capacity)

Method Summary

Modifier and TypeMethod and Description
public 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(final MessagePassingQueue.Consumer<E> c, final 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
drainTo(Collection<? super E>
the collection to transfer elements into
c
)

Implements java.util.concurrent.BlockingQueue.drainTo.

Removes all available elements from this queue and adds them to the given collection.
public int
drainTo(Collection<? super E>
the collection to transfer elements into
c
,
int
the maximum number of elements to transfer
maxElements
)

Implements java.util.concurrent.BlockingQueue.drainTo.

Removes at most the given number of available elements from this queue and adds them to the given collection.
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 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 final 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 final Iterator<E>
iterator()

Implements abstract java.util.AbstractCollection.iterator.

Implements java.util.Collection.iterator.

Returns an iterator over the elements in this collection.
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.concurrent.BlockingQueue.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.
public boolean
offer(E
the element to add
e
,
long
how long to wait before giving up, in units of unit
timeout
,
TimeUnit
a TimeUnit determining how to interpret the timeout parameter
unit
)

Implements java.util.concurrent.BlockingQueue.offer.

Inserts the specified element into this queue, waiting up to the specified wait time if necessary for space to become available.
private boolean
offerAndWakeup(E[] buffer, long mask, long pIndex, E e)

public boolean

Returns:

true if the offer is successful, false if queue size exceeds threshold
offerIfBelowThreshold
(final E
the object to offer onto the queue, not null
e
,
int
the maximum allowable size
threshold
)

offer if size() is less than threshold.

private E
parkUntilNext(E[] buffer, long cIndex, long offset, long timeoutNs)

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(long
how long to wait before giving up, in units of unit
timeout
,
TimeUnit
a TimeUnit determining how to interpret the timeout parameter
unit
)

Implements java.util.concurrent.BlockingQueue.poll.

Retrieves and removes the head of this queue, waiting up to the specified wait time if necessary for an element to become available.
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 void
put(E
the element to add
e
)

Implements java.util.concurrent.BlockingQueue.put.

Inserts the specified element into this queue, waiting if necessary for space to become available.
private boolean
recalculateProducerLimit(long mask, long pIndex, long producerLimit)

private boolean
recalculateProducerLimit(long pIndex, long producerLimit, long cIndex, long bufferCapacity, long threshold)

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
releaseParkedConsumer(Thread consumerThread)

A consumer is trapped in `parking` until the field is nulled, and this code can only be executed after it is no longer in that state.

public int
remainingCapacity()

Implements java.util.concurrent.BlockingQueue.remainingCapacity.

Returns the number of additional elements that this queue can ideally (in the absence of memory or resource constraints) accept without blocking, or Integer.MAX_VALUE if there is no intrinsic limit.
private boolean
revertParkedState(long pIndex)

Consumer must revert the `parked` state when interrupted or thewhen returning after a timeout.

public final 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.
private static <E> E
spinWaitForElement(E[] buffer, long offset)

private void
public E
take()

Implements java.util.concurrent.BlockingQueue.take.

Retrieves and removes the head of this queue, waiting if necessary until an element becomes available.
public String
toString()

Overrides java.util.AbstractCollection.toString.

Returns a string representation of this collection.
private void
Inherited from io.netty.util.internal.shaded.org.jctools.queues.MpscBlockingConsumerArrayQueueConsumerFields:
lpConsumerIndexlvBlockedlvConsumerIndexsoBlockedsoConsumerIndex