Package io.servicetalk.concurrent.api
Class BufferStrategies
- java.lang.Object
-
- io.servicetalk.concurrent.api.BufferStrategies
-
public final class BufferStrategies extends java.lang.ObjectA static factory ofBufferStrategyinstances.
-
-
Method Summary
All Methods Static Methods Concrete Methods Modifier and Type Method Description static <T> BufferStrategy<T,BufferStrategy.Accumulator<T,java.lang.Iterable<T>>,java.lang.Iterable<T>>forCountOrTime(int count, java.time.Duration duration)Returns aBufferStrategythat 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,java.lang.Iterable<T>>,java.lang.Iterable<T>>forCountOrTime(int count, java.time.Duration duration, Executor executor)Returns aBufferStrategythat 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, java.time.Duration duration, java.util.function.Supplier<BC> accumulatorSupplier)Returns aBufferStrategythat 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, java.time.Duration duration, java.util.function.Supplier<BC> accumulatorSupplier, Executor executor)Returns aBufferStrategythat creates buffer boundaries based on number of items buffered or time elapsed since the current buffer boundary started.
-
-
-
Method Detail
-
forCountOrTime
public static <T> BufferStrategy<T,BufferStrategy.Accumulator<T,java.lang.Iterable<T>>,java.lang.Iterable<T>> forCountOrTime(int count, java.time.Duration duration)
Returns aBufferStrategythat 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 returnedBufferStrategywill have exactlycountnumber 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-Durationafter which the current buffer boundary is closed, if not already closed.- Returns:
BufferStrategythat 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,java.lang.Iterable<T>>,java.lang.Iterable<T>> forCountOrTime(int count, java.time.Duration duration, Executor executor)
Returns aBufferStrategythat 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 returnedBufferStrategywill have exactlycountnumber 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-Durationafter which the current buffer boundary is closed, if not already closed.executor-Executorto use for recording the passedduration.- Returns:
BufferStrategythat 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,B>,B> BufferStrategy<T,BufferStrategy.Accumulator<T,B>,B> forCountOrTime(int count, java.time.Duration duration, java.util.function.Supplier<BC> accumulatorSupplier)
Returns aBufferStrategythat 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 returnedBufferStrategywill have exactlycountnumber 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.Accumulatorused to accumulate items in a buffer.B- Type of object created after anBufferStrategy.Accumulatorisfinished.- Parameters:
count- Number of items to add before closing the current buffer boundary, if not already closed.duration-Durationafter which the current buffer boundary is closed, if not already closed.accumulatorSupplier- ASupplierofBufferStrategy.Accumulatorevery time a buffer boundary is closed. Methods on theBufferStrategy.Accumulatorreturned from thisSuppliermay or may not be called.- Returns:
BufferStrategythat 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,B>,B> BufferStrategy<T,BufferStrategy.Accumulator<T,B>,B> forCountOrTime(int count, java.time.Duration duration, java.util.function.Supplier<BC> accumulatorSupplier, Executor executor)
Returns aBufferStrategythat 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 returnedBufferStrategywill have exactlycountnumber 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.Accumulatorused to accumulate items in a buffer.B- Type of object created after anBufferStrategy.Accumulatorisfinished.- Parameters:
count- Number of items to add before closing the current buffer boundary, if not already closed.duration-Durationafter which the current buffer boundary is closed, if not already closed.accumulatorSupplier- ASupplierofBufferStrategy.Accumulatorevery time a buffer boundary is closed. Methods on theBufferStrategy.Accumulatorreturned from thisSuppliermay or may not be called.executor-Executorto use for recording the passedduration.- Returns:
BufferStrategythat creates buffer boundaries based on number of items buffered or time elapsed since the current buffer boundary started.
-
-