Skip to content

Commit

Permalink
iostream: use new-style consumer to implement copy()
Browse files Browse the repository at this point in the history
in 62dd712, we added two concept for both the old-style
consumer which returns `std::optional<temporary_buffer>`
consumer, and the new one which returns `consumption_result`.
but somehow, we are still using the old-style in the implementation
of `copy()`.

in this change, we switch to the new-style consumer. this helps
developers to understand the usage of this consumer, and also
enables us to drop the obsolete interface in future.

Signed-off-by: Kefu Chai <[email protected]>
  • Loading branch information
tchaikov committed Jul 3, 2024
1 parent 4c7a802 commit c7adf60
Showing 1 changed file with 5 additions and 5 deletions.
10 changes: 5 additions & 5 deletions include/seastar/core/iostream-impl.hh
Original file line number Diff line number Diff line change
Expand Up @@ -527,16 +527,16 @@ template <typename CharType>
struct stream_copy_consumer {
private:
output_stream<CharType>& _os;
using unconsumed_remainder = std::optional<temporary_buffer<CharType>>;
using consumption_result_type = consumption_result<CharType>;
public:
stream_copy_consumer(output_stream<CharType>& os) : _os(os) {
}
future<unconsumed_remainder> operator()(temporary_buffer<CharType> data) {
future<consumption_result_type> operator()(temporary_buffer<CharType> data) {
if (data.empty()) {
return make_ready_future<unconsumed_remainder>(std::move(data));
return make_ready_future<consumption_result_type>(stop_consuming(std::move(data)));
}
return _os.write(data.get(), data.size()).then([] () {
return make_ready_future<unconsumed_remainder>();
return _os.write(data.get(), data.size()).then([] {
return make_ready_future<consumption_result_type>(continue_consuming());
});
}
};
Expand Down

0 comments on commit c7adf60

Please sign in to comment.