Class FullDrainMpscQueue<T>

java.lang.Object
pl.allegro.tech.hermes.consumers.queue.FullDrainMpscQueue<T>
All Implemented Interfaces:
MpscQueue<T>

public class FullDrainMpscQueue<T> extends Object implements MpscQueue<T>
  • Constructor Summary

    Constructors
    Constructor
    Description
    FullDrainMpscQueue(int capacity)
     
  • Method Summary

    Modifier and Type
    Method
    Description
    int
     
    void
    drain(org.jctools.queues.MessagePassingQueue.Consumer<T> consumer)
    The MpscArrayQueue.drain(MessagePassingQueue.Consumer) method may skip items with allocated slots by producers (who won CAS) but were not added to the queue yet.
    boolean
    offer(T element)
     
    int
     

    Methods inherited from class java.lang.Object

    clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
  • Constructor Details

    • FullDrainMpscQueue

      public FullDrainMpscQueue(int capacity)
  • Method Details

    • offer

      public boolean offer(T element)
      Specified by:
      offer in interface MpscQueue<T>
    • drain

      public void drain(org.jctools.queues.MessagePassingQueue.Consumer<T> consumer)

      The MpscArrayQueue.drain(MessagePassingQueue.Consumer) method may skip items with allocated slots by producers (who won CAS) but were not added to the queue yet. This may happen to broken elements chain. See explanation here.

      This is an alternative approach which waits for all items to become available by using MpscArrayQueue.poll() underneath (which spin-waits when getting next item).

      Specified by:
      drain in interface MpscQueue<T>
    • size

      public int size()
      Specified by:
      size in interface MpscQueue<T>
    • capacity

      public int capacity()
      Specified by:
      capacity in interface MpscQueue<T>