Interface Pipe<E>

All Known Subinterfaces:
QueuedPipe<E>
All Known Implementing Classes:
AbstractConcurrentArrayQueue, ManyToManyConcurrentArrayQueue, ManyToOneConcurrentArrayQueue, OneToOneConcurrentArrayQueue

public interface Pipe<E>
A container for items exchanged from producers to consumers.
  • Method Summary

    Modifier and Type
    Method
    Description
    long
    The number of items added to this container since creation.
    int
    The maximum capacity of this container to hold items.
    int
    drain(Consumer<E> elementConsumer)
    Drain the number of elements present in a collection at the time the operation starts.
    int
    drain(Consumer<E> elementConsumer, int limit)
    Drain the minimum of a limit and the number of elements present in a collection at the time the operation starts.
    int
    drainTo(Collection<? super E> target, int limit)
    Drain available elements into the provided Collection up to a provided maximum limit of elements.
    int
    Get the remaining capacity for elements in the container given the current size.
    long
    The number of items removed from this container since creation.
    int
    The number of items currently in the container.
  • Method Details

    • addedCount

      long addedCount()
      The number of items added to this container since creation.
      Returns:
      the number of items added.
    • removedCount

      long removedCount()
      The number of items removed from this container since creation.
      Returns:
      the number of items removed.
    • capacity

      int capacity()
      The maximum capacity of this container to hold items.
      Returns:
      the capacity of the container.
    • size

      int size()
      The number of items currently in the container.
      Returns:
      number of items currently in the container.
    • remainingCapacity

      int remainingCapacity()
      Get the remaining capacity for elements in the container given the current size.
      Returns:
      remaining capacity of the container.
    • drain

      int drain(Consumer<E> elementConsumer)
      Drain the number of elements present in a collection at the time the operation starts.

      If possible, implementations should use smart batching to best handle burst traffic.

      Parameters:
      elementConsumer - Consumer for processing elements.
      Returns:
      the number of elements drained.
    • drain

      int drain(Consumer<E> elementConsumer, int limit)
      Drain the minimum of a limit and the number of elements present in a collection at the time the operation starts.

      If possible, implementations should use smart batching to best handle burst traffic.

      Parameters:
      elementConsumer - Consumer for processing elements.
      limit - maximum number of elements to be drained in a drain operation.
      Returns:
      the number of elements drained.
    • drainTo

      int drainTo(Collection<? super E> target, int limit)
      Drain available elements into the provided Collection up to a provided maximum limit of elements.

      If possible, implementations should use smart batching to best handle burst traffic.

      Parameters:
      target - in to which elements are drained.
      limit - maximum number of elements to be drained in a drain operation.
      Returns:
      the number of elements actually drained.