Package io.servicetalk.concurrent.api
Interface BufferStrategy<T,BC extends BufferStrategy.Accumulator<T,B>,B>
-
- Type Parameters:
T- items emitted from thePublisherwhich 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 forbufferingitems emitted from aPublisher.A buffer strategy represents
asynchronous buffer boundariesover which items from aPublisherare buffered. Each item emitted from the boundaryPublisherrepresents the end of the last boundary and start of the next boundary. The first item emitted from thisPublisheris treated as the start of the first boundary andPublisher.buffer(BufferStrategy)may decide to defer requesting items from thePublisheron which that operator is applied.
-
-
Nested Class Summary
Nested Classes Modifier and Type Interface Description static interfaceBufferStrategy.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 aPublisherrepresenting asynchronous buffer boundaries.intbufferSizeHint()A rough estimate of the number of items in a buffer.
-
-
-
Method Detail
-
boundaries
Publisher<BC> boundaries()
Returns aPublisherrepresenting asynchronous buffer boundaries. ThisPublisheris expected to be an infinitePublisher. Hence, it should never terminate anyPublisherSource.Subscribersubscribed to it. InsteadPublisherSource.Subscribers will alwayscanceltheirPublisherSource.Subscription. If this expectation is violated, buffered items may be discarded.- Returns:
- A
Publisherrepresenting 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.
-
-