Class BlockingMpscQueue<T>

  • All Implemented Interfaces:
    java.lang.Iterable<T>, java.util.Collection<T>, java.util.concurrent.BlockingQueue<T>, java.util.Queue<T>, BatchedBlockingQueue<T>, org.jctools.queues.IndexedQueueSizeUtil.IndexedQueue, org.jctools.queues.MessagePassingQueue<T>, org.jctools.queues.QueueProgressIndicators

    public class BlockingMpscQueue<T>
    extends org.jctools.queues.MpscArrayQueue<T>
    implements java.util.concurrent.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 java.lang.Object>, org.jctools.queues.MessagePassingQueue.ExitCondition, org.jctools.queues.MessagePassingQueue.Supplier<T extends java.lang.Object>, org.jctools.queues.MessagePassingQueue.WaitStrategy
    • Field Summary

      Modifier and Type Field Description
      protected long consumerIndex  
      • Fields inherited from class org.jctools.queues.ConcurrentCircularArrayQueue

        buffer, mask
      • Fields inherited from interface org.jctools.queues.MessagePassingQueue

    • Constructor Summary

      Constructor Description
      BlockingMpscQueue​(int size)  
    • Method Summary

      All Methods Instance Methods Concrete Methods 
      Modifier and Type Method Description
      protected boolean casProducerIndex​(long arg0, long arg1)  
      int drainTo​(java.util.Collection<? super T> c)  
      int drainTo​(java.util.Collection<? super T> c, int maxElements)  
      protected long lpConsumerIndex()  
      long lvConsumerIndex()  
      long lvProducerIndex()  
      protected long lvProducerLimit()  
      boolean offer​(T e, long timeout, java.util.concurrent.TimeUnit unit)  
      T poll​(long timeout, java.util.concurrent.TimeUnit unit)  
      int pollAll​(T[] array, long timeout, java.util.concurrent.TimeUnit unit)
      Removes multiple items from the queue.
      void put​(T e)  
      void putAll​(T[] a, int offset, int len)  
      int remainingCapacity()  
      protected void soConsumerIndex​(long arg0)  
      protected void soProducerLimit​(long arg0)  
      T take()  
      int takeAll​(T[] array)
      Drain the queue into an array.
      • Methods inherited from class org.jctools.queues.MpscArrayQueue

        drain, drain, drain, failFastOffer, fill, fill, fill, offer, offerIfBelowThreshold, peek, poll, relaxedOffer, relaxedPeek, relaxedPoll
      • Methods inherited from class org.jctools.queues.ConcurrentCircularArrayQueue

        calcElementOffset, calcElementOffset, capacity, clear, currentConsumerIndex, currentProducerIndex, isEmpty, iterator, size, toString
      • Methods inherited from class java.util.AbstractQueue

        add, addAll, element, remove
      • Methods inherited from class java.util.AbstractCollection

        contains, containsAll, remove, removeAll, retainAll, toArray, toArray
      • Methods inherited from class java.lang.Object

        clone, equals, finalize, getClass, hashCode, notify, notifyAll, wait, wait, wait
      • Methods inherited from interface java.util.concurrent.BlockingQueue

        add, contains, offer, remove
      • Methods inherited from interface java.util.Collection

        addAll, clear, containsAll, equals, hashCode, isEmpty, iterator, parallelStream, removeAll, removeIf, retainAll, size, spliterator, stream, toArray, toArray
      • Methods inherited from interface java.lang.Iterable

      • Methods inherited from interface java.util.Queue

        element, peek, poll, remove
    • Field Detail

      • consumerIndex

        protected long consumerIndex
    • Constructor Detail

      • BlockingMpscQueue

        public BlockingMpscQueue​(int size)
    • Method Detail

      • put

        public void put​(T e)
                 throws java.lang.InterruptedException
        Specified by:
        put in interface java.util.concurrent.BlockingQueue<T>
      • offer

        public boolean offer​(T e,
                             long timeout,
                             java.util.concurrent.TimeUnit unit)
                      throws java.lang.InterruptedException
        Specified by:
        offer in interface java.util.concurrent.BlockingQueue<T>
      • take

        public T take()
               throws java.lang.InterruptedException
        Specified by:
        take in interface java.util.concurrent.BlockingQueue<T>
      • poll

        public T poll​(long timeout,
                      java.util.concurrent.TimeUnit unit)
               throws java.lang.InterruptedException
        Specified by:
        poll in interface java.util.concurrent.BlockingQueue<T>
      • remainingCapacity

        public int remainingCapacity()
        Specified by:
        remainingCapacity in interface java.util.concurrent.BlockingQueue<T>
      • drainTo

        public int drainTo​(java.util.Collection<? super T> c)
        Specified by:
        drainTo in interface java.util.concurrent.BlockingQueue<T>
      • drainTo

        public int drainTo​(java.util.Collection<? super T> c,
                           int maxElements)
        Specified by:
        drainTo in interface java.util.concurrent.BlockingQueue<T>
      • putAll

        public void putAll​(T[] a,
                           int offset,
                           int len)
                    throws java.lang.InterruptedException
        Specified by:
        putAll in interface BatchedBlockingQueue<T>
      • takeAll

        public int takeAll​(T[] array)
                    throws java.lang.InterruptedException
        Description copied from interface: BatchedBlockingQueue
        Drain the queue into an array. Wait if there are no items in the queue.
        Specified by:
        takeAll in interface BatchedBlockingQueue<T>
      • pollAll

        public int pollAll​(T[] array,
                           long timeout,
                           java.util.concurrent.TimeUnit unit)
                    throws java.lang.InterruptedException
        Description copied from interface: BatchedBlockingQueue
        Removes multiple items from the queue. The method returns when either: 1. At least one item is available 2. The timeout expires
        Specified by:
        pollAll in interface BatchedBlockingQueue<T>
      • lpConsumerIndex

        protected final long lpConsumerIndex()
      • lvConsumerIndex

        public final long lvConsumerIndex()
      • soConsumerIndex

        protected void soConsumerIndex​(long arg0)
      • lvProducerLimit

        protected final long lvProducerLimit()
      • soProducerLimit

        protected final void soProducerLimit​(long arg0)
      • lvProducerIndex

        public final long lvProducerIndex()
      • casProducerIndex

        protected final boolean casProducerIndex​(long arg0,
                                                 long arg1)