Class BlockingMpscQueue<T>
java.lang.Object
java.util.AbstractCollection<E>
java.util.AbstractQueue<E>
org.jctools.queues.MpscArrayQueue<T>
org.apache.bookkeeper.common.collections.BlockingMpscQueue<T>
- All Implemented Interfaces:
Iterable<T>,Collection<T>,BlockingQueue<T>,Queue<T>,BatchedBlockingQueue<T>,org.jctools.queues.IndexedQueueSizeUtil.IndexedQueue,org.jctools.queues.MessagePassingQueue<T>,org.jctools.queues.QueueProgressIndicators,org.jctools.queues.SupportsIterator
public class BlockingMpscQueue<T>
extends org.jctools.queues.MpscArrayQueue<T>
implements BlockingQueue<T>, BatchedBlockingQueue<T>
Blocking queue optimized for multiple producers and single consumer.
-
Nested Class Summary
Nested classes/interfaces inherited from interface org.jctools.queues.MessagePassingQueue
org.jctools.queues.MessagePassingQueue.Consumer<T extends Object>, org.jctools.queues.MessagePassingQueue.ExitCondition, org.jctools.queues.MessagePassingQueue.Supplier<T extends Object>, org.jctools.queues.MessagePassingQueue.WaitStrategy -
Field Summary
FieldsFields inherited from interface org.jctools.queues.MessagePassingQueue
UNBOUNDED_CAPACITY -
Constructor Summary
Constructors -
Method Summary
Modifier and TypeMethodDescriptionintcapacity()voidclear()longlongintdrainTo(Collection<? super T> c) intdrainTo(Collection<? super T> c, int maxElements) booleanisEmpty()iterator()final longfinal longbooleanintRemoves multiple items from the queue.voidvoidintintsize()take()intDrain the queue into an array.toString()Methods inherited from class org.jctools.queues.MpscArrayQueue
drain, drain, drain, failFastOffer, fill, fill, fill, offer, offerIfBelowThreshold, peek, poll, relaxedOffer, relaxedPeek, relaxedPollMethods inherited from class java.util.AbstractQueue
add, addAll, element, removeMethods inherited from class java.util.AbstractCollection
contains, containsAll, remove, removeAll, retainAll, toArray, toArrayMethods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, wait, wait, waitMethods inherited from interface java.util.concurrent.BlockingQueue
add, contains, offer, removeMethods inherited from interface java.util.Collection
addAll, clear, containsAll, equals, hashCode, isEmpty, iterator, parallelStream, removeAll, removeIf, retainAll, size, spliterator, stream, toArray, toArray, toArray
-
Field Details
-
mask
protected final long mask -
buffer
-
-
Constructor Details
-
BlockingMpscQueue
public BlockingMpscQueue(int size)
-
-
Method Details
-
put
- Specified by:
putin interfaceBlockingQueue<T>- Throws:
InterruptedException
-
offer
- Specified by:
offerin interfaceBlockingQueue<T>- Throws:
InterruptedException
-
take
- Specified by:
takein interfaceBlockingQueue<T>- Throws:
InterruptedException
-
poll
- Specified by:
pollin interfaceBlockingQueue<T>- Throws:
InterruptedException
-
remainingCapacity
public int remainingCapacity()- Specified by:
remainingCapacityin interfaceBlockingQueue<T>
-
drainTo
- Specified by:
drainToin interfaceBlockingQueue<T>
-
drainTo
- Specified by:
drainToin interfaceBlockingQueue<T>
-
putAll
- Specified by:
putAllin interfaceBatchedBlockingQueue<T>- Throws:
InterruptedException
-
takeAll
Description copied from interface:BatchedBlockingQueueDrain the queue into an array. Wait if there are no items in the queue.- Specified by:
takeAllin interfaceBatchedBlockingQueue<T>- Returns:
- Throws:
InterruptedException
-
pollAll
Description copied from interface:BatchedBlockingQueueRemoves multiple items from the queue. The method returns when either: 1. At least one item is available 2. The timeout expires- Specified by:
pollAllin interfaceBatchedBlockingQueue<T>- Returns:
- Throws:
InterruptedException
-
lvConsumerIndex
public final long lvConsumerIndex() -
lvProducerIndex
public final long lvProducerIndex() -
size
public int size()- Specified by:
sizein interfaceCollection<E extends Object>- Specified by:
sizein interfaceorg.jctools.queues.MessagePassingQueue<E extends Object>- Specified by:
sizein classAbstractCollection<E extends Object>
-
isEmpty
public boolean isEmpty()- Specified by:
isEmptyin interfaceCollection<E extends Object>- Specified by:
isEmptyin interfaceorg.jctools.queues.MessagePassingQueue<E extends Object>- Overrides:
isEmptyin classAbstractCollection<E extends Object>
-
toString
- Overrides:
toStringin classAbstractCollection<E extends Object>
-
clear
public void clear()- Specified by:
clearin interfaceCollection<E extends Object>- Specified by:
clearin interfaceorg.jctools.queues.MessagePassingQueue<E extends Object>- Overrides:
clearin classAbstractQueue<E extends Object>
-
capacity
public int capacity()- Specified by:
capacityin interfaceorg.jctools.queues.IndexedQueueSizeUtil.IndexedQueue- Specified by:
capacityin interfaceorg.jctools.queues.MessagePassingQueue<E extends Object>
-
currentProducerIndex
public long currentProducerIndex()- Specified by:
currentProducerIndexin interfaceorg.jctools.queues.QueueProgressIndicators
-
currentConsumerIndex
public long currentConsumerIndex()- Specified by:
currentConsumerIndexin interfaceorg.jctools.queues.QueueProgressIndicators
-
iterator
- Specified by:
iteratorin interfaceCollection<E extends Object>- Specified by:
iteratorin interfaceIterable<E extends Object>- Specified by:
iteratorin classAbstractCollection<E extends Object>
-