Interface AsyncStream<T>

Type Parameters:
T - the type of the stream elements
All Superinterfaces:
AutoCloseable, BaseStream<T,Stream<T>>, Stream<T>

public interface AsyncStream<T> extends Stream<T>

Interface for asynchronous streams.

This adds asynchronous methods for all terminal operations returning completable futures. When these methods are called the stream pipeline is run asynchronously as data is pushed to the stream.

Default implementations of these new methods simply execute their synchronous counterparts and return the result wrapped in a completed future.

The implementation works by separating the terminal operation from the rest of the stream. The non-terminal part of the stream is then surrounded by 2 (spl)iterators that are controlled by the thread supplying the new data. The terminal operation is also executed by the supplier thread everytime an element comes out of the non-terminal part of the stream.