Class MpscIntQueue.MpscAtomicIntegerArrayQueue

java.lang.Object
java.util.concurrent.atomic.AtomicIntegerArray
io.netty.util.concurrent.MpscIntQueue.MpscAtomicIntegerArrayQueue
All Implemented Interfaces:
MpscIntQueue, Serializable
Enclosing interface:
MpscIntQueue

public static final class MpscIntQueue.MpscAtomicIntegerArrayQueue extends AtomicIntegerArray implements MpscIntQueue
This implementation is based on MpscAtomicUnpaddedArrayQueue from JCTools.
See Also:
  • Constructor Details

    • MpscAtomicIntegerArrayQueue

      public MpscAtomicIntegerArrayQueue(int capacity, int emptyValue)
  • Method Details

    • offer

      public boolean offer(int value)
      Description copied from interface: MpscIntQueue
      Offer the given value to the queue. This will throw an exception if the given value is the "empty" value.
      Specified by:
      offer in interface MpscIntQueue
      Parameters:
      value - The value to add to the queue.
      Returns:
      true if the value was added to the queue, or false if the value could not be added because the queue is full.
    • poll

      public int poll()
      Description copied from interface: MpscIntQueue
      Remove and return the next value from the queue, or return the "empty" value if the queue is empty.
      Specified by:
      poll in interface MpscIntQueue
      Returns:
      The next value or the "empty" value.
    • drain

      public int drain(int limit, IntConsumer consumer)
      Description copied from interface: MpscIntQueue
      Remove up to the given limit of elements from the queue, and pass them to the consumer in order.
      Specified by:
      drain in interface MpscIntQueue
      Parameters:
      limit - The maximum number of elements to dequeue.
      consumer - The consumer to pass the removed elements to.
      Returns:
      The actual number of elements removed.
    • fill

      public int fill(int limit, IntSupplier supplier)
      Description copied from interface: MpscIntQueue
      Add up to the given limit of elements to this queue, from the given supplier.
      Specified by:
      fill in interface MpscIntQueue
      Parameters:
      limit - The maximum number of elements to enqueue.
      supplier - The supplier to obtain the elements from.
      Returns:
      The actual number of elements added.
    • isEmpty

      public boolean isEmpty()
      Description copied from interface: MpscIntQueue
      Query if the queue is empty or not.

      This method is inherently racy and the result may be out of date by the time the method returns.

      Specified by:
      isEmpty in interface MpscIntQueue
      Returns:
      true if the queue was observed to be empty, otherwise
      invalid @code
      {@code false.
    • size

      public int size()
      Description copied from interface: MpscIntQueue
      Query the number of elements currently in the queue.

      This method is inherently racy and the result may be out of date by the time the method returns.

      Specified by:
      size in interface MpscIntQueue
      Returns:
      An estimate of the number of elements observed in the queue.