Package org.agrona.concurrent
Interface Pipe<E>
-
- Type Parameters:
E
- type of the pipe elements.
- 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
All Methods Instance Methods Abstract Methods Modifier and Type Method Description long
addedCount()
The number of items added to this container since creation.int
capacity()
The maximum capacity of this container to hold items.int
drain(java.util.function.Consumer<E> elementConsumer)
Drain the number of elements present in a collection at the time the operation starts.int
drain(java.util.function.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(java.util.Collection<? super E> target, int limit)
Drain available elements into the providedCollection
up to a provided maximum limit of elements.int
remainingCapacity()
Get the remaining capacity for elements in the container given the current size.long
removedCount()
The number of items removed from this container since creation.int
size()
The number of items currently in the container.
-
-
-
Method Detail
-
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(java.util.function.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(java.util.function.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(java.util.Collection<? super E> target, int limit)
Drain available elements into the providedCollection
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.
-
-