mirror of
https://github.com/scylladb/scylladb.git
synced 2026-04-20 00:20:47 +00:00
Our input_stream::consume() mechanism allows feeding data from an input stream into a consumer, piece by piece, until the consumer doesn't want any more. It currently assumed the input can block (when reading from disk), but the consumption is assumed to be immediate. This patch adds support for blocking in the consumption function: The consumer now returns a future which it promises to fulfill after consuming the given buffer. This patch goes further by somewhat simplifying (?) the interface of the consumer. Instead of receiving a mysterious "done" lambda the consumer is supposed to call when done (doesn't want any more input), the consumer now returns a future<optional<temporary_buffer<char>>, which means: 1. The future is fulfilled when the consumer is done with this buffer and either wants more - or wants to stop. 2. If the consumer wants to stop, it returns the *remaining* part of the buffer it didn't want to process (this will be pushed back into the input stream). 3. If the consumer is not done, and wants to consume more, it returns an unset optional. Signed-off-by: Nadav Har'El <nyh@cloudius-systems.com>