T - items emitted from the Publisher which are to be buffered using this BufferStrategy.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>
buffering items emitted from a Publisher.
A buffer strategy represents asynchronous buffer boundaries over which items from a
Publisher are buffered. Each item emitted from the boundary Publisher represents the end of the
last boundary and start of the next boundary. The first item emitted from this Publisher is treated as the
start of the first boundary and Publisher.buffer(BufferStrategy) may decide to defer requesting items from
the Publisher on which that operator is applied.
| Modifier and Type | Interface and Description |
|---|---|
static interface |
BufferStrategy.Accumulator<T,B>
An intermediate mutable object that holds items till it is
finished. |
| Modifier and Type | Method and Description |
|---|---|
Publisher<BC> |
boundaries()
Returns a
Publisher representing asynchronous buffer boundaries. |
int |
bufferSizeHint()
A rough estimate of the number of items in a buffer.
|
Publisher<BC> boundaries()
Publisher representing asynchronous buffer boundaries.
Notes:
Publisher is expected to be an infinite Publisher. Hence, it should never terminate
any PublisherSource.Subscriber subscribed to it. Instead PublisherSource.Subscribers will always
cancel their PublisherSource.Subscription. If this expectation is violated, buffered
items may be discarded.Publisher returns more boundaries faster than accumulation or emission of the previous
boundary can be processed, these new boundaries may be discarded without invocation of either
BufferStrategy.Accumulator.accumulate(Object) or BufferStrategy.Accumulator.finish() methods. Avoid initializing expensive
state before any of the BufferStrategy.Accumulator methods are invoked.Publisher representing asynchronous buffer boundaries.int bufferSizeHint()
Note: if boundaries() are generated based on the number of accumulated items, this hint size MUST always
be equal or less than the number of items that generates a boundary. Otherwise, there is a risk of emitting more
buffers than requested.