Package io.servicetalk.concurrent.api
Interface BufferStrategy<T,BC extends BufferStrategy.Accumulator<T,B>,B>
-
- Type Parameters:
T
- items emitted from thePublisher
which are to be buffered using thisBufferStrategy
.BC
- An intermediate mutable object that holds the items into a buffer before it is emitted.B
- The buffer of items.
public interface BufferStrategy<T,BC extends BufferStrategy.Accumulator<T,B>,B>
A strategy forbuffering
items emitted from aPublisher
.A buffer strategy represents
asynchronous buffer boundaries
over which items from aPublisher
are buffered. Each item emitted from the boundaryPublisher
represents the end of the last boundary and start of the next boundary. The first item emitted from thisPublisher
is treated as the start of the first boundary andPublisher.buffer(BufferStrategy)
may decide to defer requesting items from thePublisher
on which that operator is applied.
-
-
Nested Class Summary
Nested Classes Modifier and Type Interface Description static interface
BufferStrategy.Accumulator<T,B>
An intermediate mutable object that holds items till it isfinished
.
-
Method Summary
All Methods Instance Methods Abstract Methods Modifier and Type Method Description Publisher<BC>
boundaries()
Returns aPublisher
representing asynchronous buffer boundaries.int
bufferSizeHint()
A rough estimate of the number of items in a buffer.
-
-
-
Method Detail
-
boundaries
Publisher<BC> boundaries()
Returns aPublisher
representing asynchronous buffer boundaries. ThisPublisher
is expected to be an infinitePublisher
. Hence, it should never terminate anyPublisherSource.Subscriber
subscribed to it. InsteadPublisherSource.Subscriber
s will alwayscancel
theirPublisherSource.Subscription
. If this expectation is violated, buffered items may be discarded.- Returns:
- A
Publisher
representing asynchronous buffer boundaries.
-
bufferSizeHint
int bufferSizeHint()
A rough estimate of the number of items in a buffer.- Returns:
- A rough estimate of the number of items in a buffer.
-
-