public interface BlockingStream<U>
Modifier and Type | Method and Description |
---|---|
default java.util.List<U> |
block()
React and block
|
default <R,A> R |
block(java.util.stream.Collector<? super U,A,R> collector) |
default <R> R |
blockAndExtract(Extractor extractor)
Block until tasks complete and return a value determined by the extractor
supplied.
|
default <R> R |
blockAndExtract(Extractor extractor,
java.util.function.Predicate<Status> breakout)
Block until tasks complete, or breakout conditions met and return a value
determined by the extractor supplied.
|
default U |
first()
Block until first result received
|
java.util.Optional<java.util.function.Consumer<java.lang.Throwable>> |
getErrorHandler() |
java.lang.Object |
getLastActive() |
default U |
last()
Block until all results received.
|
java.util.Optional<java.util.function.Consumer<java.lang.Throwable>> getErrorHandler()
default java.util.List<U> block()
List<String> strings = new SimpleReact().<Integer, Integer> react(() -> 1, () -> 2, () -> 3)
.then((it) -> it * 100)
.then((it) -> "*" + it)
.block();
In this example, once the current thread of execution meets the React
block method, it will block until all tasks have been completed. The
result will be returned as a List. The Reactive tasks triggered by the
Suppliers are non-blocking, and are not impacted by the block method
until they are complete. Block, only blocks the current thread.java.lang.Object getLastActive()
default <R,A> R block(java.util.stream.Collector<? super U,A,R> collector)
collector
- to perform aggregation / reduction operation on the results
(e.g. to Collect into a List or String)default U first()
default U last()
default <R> R blockAndExtract(Extractor extractor)
extractor
- used to determine which value should be returned, recieves
current collected input and extracts a return valuedefault <R> R blockAndExtract(Extractor extractor, java.util.function.Predicate<Status> breakout)
extractor
- used to determine which value should be returned, recieves
current collected input and extracts a return valuebreakout
- Predicate that determines whether the block should be
continued or removed