An extension of
Consumer used to conduct values through the stages of
a stream pipeline, with additional methods to manage size information,
control flow, etc. Before calling the
accept() method on a
Sink for the first time, you must first call the
begin()method to inform it that data is coming (optionally informing the sink how
much data is coming), and after all data has been sent, you must call the
end() method. After calling
end(), you should not call
accept() without again calling
begin().
Sink also
offers a mechanism by which the sink can cooperatively signal that it does
not wish to receive any more data (the
cancellationRequested()method), which a source can poll before sending more data to the
Sink.
A sink may be in one of two states: an initial state and an active state.
It starts out in the initial state; the
begin() method transitions
it to the active state, and the
end() method transitions it back into
the initial state, where it can be re-used. Data-accepting methods (such as
accept() are only valid in the active state.