Package io.servicetalk.concurrent.api
Class BufferStrategies
java.lang.Object
io.servicetalk.concurrent.api.BufferStrategies
A static factory of
BufferStrategy
instances.-
Method Summary
Modifier and TypeMethodDescriptionstatic <T> BufferStrategy<T,
BufferStrategy.Accumulator<T, Iterable<T>>, Iterable<T>> forCountOrTime
(int count, Duration duration) Returns aBufferStrategy
that creates buffer boundaries based on number of items buffered or time elapsed since the current buffer boundary started.static <T> BufferStrategy<T,
BufferStrategy.Accumulator<T, Iterable<T>>, Iterable<T>> forCountOrTime
(int count, Duration duration, Executor executor) Returns aBufferStrategy
that creates buffer boundaries based on number of items buffered or time elapsed since the current buffer boundary started.static <T,
BC extends BufferStrategy.Accumulator<T, B>, B>
BufferStrategy<T,BufferStrategy.Accumulator<T, B>, B> forCountOrTime
(int count, Duration duration, Supplier<BC> accumulatorSupplier) Returns aBufferStrategy
that creates buffer boundaries based on number of items buffered or time elapsed since the current buffer boundary started.static <T,
BC extends BufferStrategy.Accumulator<T, B>, B>
BufferStrategy<T,BufferStrategy.Accumulator<T, B>, B> forCountOrTime
(int count, Duration duration, Supplier<BC> accumulatorSupplier, Executor executor) Returns aBufferStrategy
that creates buffer boundaries based on number of items buffered or time elapsed since the current buffer boundary started.
-
Method Details
-
forCountOrTime
public static <T> BufferStrategy<T,BufferStrategy.Accumulator<T, forCountOrTimeIterable<T>>, Iterable<T>> (int count, Duration duration) Returns aBufferStrategy
that creates buffer boundaries based on number of items buffered or time elapsed since the current buffer boundary started. This does not guarantee that the emitted buffers after applying the returnedBufferStrategy
will have exactlycount
number of items. The emitted buffers may have less or more items than thecount
.- Type Parameters:
T
- Type of items added to the buffer.- Parameters:
count
- Number of items to add before closing the current buffer boundary, if not already closed. The emitted buffers may have less or more items than thiscount
.duration
-Duration
after which the current buffer boundary is closed, if not already closed.- Returns:
BufferStrategy
that creates buffer boundaries based on number of items buffered or time elapsed since the current buffer boundary started.
-
forCountOrTime
public static <T> BufferStrategy<T,BufferStrategy.Accumulator<T, forCountOrTimeIterable<T>>, Iterable<T>> (int count, Duration duration, Executor executor) Returns aBufferStrategy
that creates buffer boundaries based on number of items buffered or time elapsed since the current buffer boundary started. This does not guarantee that the emitted buffers after applying the returnedBufferStrategy
will have exactlycount
number of items. The emitted buffers may have less or more items than thecount
.- Type Parameters:
T
- Type of items added to the buffer.- Parameters:
count
- Number of items to add before closing the current buffer boundary, if not already closed.duration
-Duration
after which the current buffer boundary is closed, if not already closed.executor
-Executor
to use for recording the passedduration
.- Returns:
BufferStrategy
that creates buffer boundaries based on number of items buffered or time elapsed since the current buffer boundary started.
-
forCountOrTime
public static <T,BC extends BufferStrategy.Accumulator<T, BufferStrategy<T,B>, B> BufferStrategy.Accumulator<T, forCountOrTimeB>, B> (int count, Duration duration, Supplier<BC> accumulatorSupplier) Returns aBufferStrategy
that creates buffer boundaries based on number of items buffered or time elapsed since the current buffer boundary started. This does not guarantee that the emitted buffers after applying the returnedBufferStrategy
will have exactlycount
number of items. The emitted buffers may have less or more items than thecount
.- Type Parameters:
T
- Type of items added to the buffer.BC
- Type ofBufferStrategy.Accumulator
used to accumulate items in a buffer.B
- Type of object created after anBufferStrategy.Accumulator
isfinished
.- Parameters:
count
- Number of items to add before closing the current buffer boundary, if not already closed.duration
-Duration
after which the current buffer boundary is closed, if not already closed.accumulatorSupplier
- ASupplier
ofBufferStrategy.Accumulator
every time a buffer boundary is closed. Methods on theBufferStrategy.Accumulator
returned from thisSupplier
may or may not be called.- Returns:
BufferStrategy
that creates buffer boundaries based on number of items buffered or time elapsed since the current buffer boundary started.
-
forCountOrTime
public static <T,BC extends BufferStrategy.Accumulator<T, BufferStrategy<T,B>, B> BufferStrategy.Accumulator<T, forCountOrTimeB>, B> (int count, Duration duration, Supplier<BC> accumulatorSupplier, Executor executor) Returns aBufferStrategy
that creates buffer boundaries based on number of items buffered or time elapsed since the current buffer boundary started. This does not guarantee that the emitted buffers after applying the returnedBufferStrategy
will have exactlycount
number of items. The emitted buffers may have less or more items than thecount
.- Type Parameters:
T
- Type of items added to the buffer.BC
- Type ofBufferStrategy.Accumulator
used to accumulate items in a buffer.B
- Type of object created after anBufferStrategy.Accumulator
isfinished
.- Parameters:
count
- Number of items to add before closing the current buffer boundary, if not already closed.duration
-Duration
after which the current buffer boundary is closed, if not already closed.accumulatorSupplier
- ASupplier
ofBufferStrategy.Accumulator
every time a buffer boundary is closed. Methods on theBufferStrategy.Accumulator
returned from thisSupplier
may or may not be called.executor
-Executor
to use for recording the passedduration
.- Returns:
BufferStrategy
that creates buffer boundaries based on number of items buffered or time elapsed since the current buffer boundary started.
-