java.lang.Object
net.pincette.rs.ProcessorBase<T,R>
net.pincette.rs.Buffered<T,List<T>>
net.pincette.rs.Per<T>
- Type Parameters:
T
- the value type.
- All Implemented Interfaces:
Flow.Processor<T,
,List<T>> Flow.Publisher<List<T>>
,Flow.Subscriber<T>
Buffers a number of values. It always requests the number of values from the publisher that
equals the buffer size. It emits the buffered values as a list. This processor uses a shared
thread.
- Since:
- 2.0
- Author:
- Werner Donné
-
Field Summary
Fields inherited from class net.pincette.rs.ProcessorBase
subscriber, subscription
-
Constructor Summary
Constructors -
Method Summary
Modifier and TypeMethodDescriptionprotected void
last()
This is called when the stream has completed.boolean
onNextAction
(T value) TheonNext
method uses this method.void
onSubscribe
(Flow.Subscription subscription) static <T> Flow.Processor<T,
List<T>> per
(int size) static <T> Flow.Processor<T,
List<T>> static <T> Flow.Processor<T,
List<T>> Methods inherited from class net.pincette.rs.Buffered
addValues, cancelling, emit, emit, getRequested, isCancelled, isCompleted, onComplete, onError, onNext
-
Constructor Details
-
Per
public Per(int size) Create a buffer ofsize
. TherequestTimeout
is set to 0.- Parameters:
size
- the buffer size, which must be larger than zero.
-
Per
Create a buffer ofsize
with a timeout. TherequestTimeout
is set to 0.- Parameters:
size
- the buffer size, which must be larger than zero.timeout
- the timeout after which the buffer is flushed. It should be positive.
-
Per
Create a buffer ofsize
with a timeout.- Parameters:
size
- the buffer size, which must be larger than zero.timeout
- the timeout after which the buffer is flushed. It should be positive.requestTimeout
- the time after which an additional element is requested, even if the upstream publisher hasn't sent all requested elements yet. This provides the opportunity to the publisher to complete properly when it has fewer elements left than the buffer size. It may benull
.- Since:
- 3.0.2
-
-
Method Details
-
per
-
per
-
per
public static <T> Flow.Processor<T,List<T>> per(int size, Duration timeout, Duration requestTimeout) -
last
protected void last()Description copied from class:Buffered
This is called when the stream has completed. It provides subclasses with the opportunity to flush any remaining data to the buffer. -
onNextAction
Description copied from class:Buffered
TheonNext
method uses this method.- Specified by:
onNextAction
in classBuffered<T,
List<T>> - Parameters:
value
- the received value.- Returns:
- Indicated if values have been added or not.
-
onSubscribe
- Specified by:
onSubscribe
in interfaceFlow.Subscriber<T>
- Overrides:
onSubscribe
in classBuffered<T,
List<T>>
-