From bcafd1b33340109d6c2dfcf8607f6853097c33f9 Mon Sep 17 00:00:00 2001 From: Denis Blank Date: Sat, 8 Dec 2018 02:32:39 +0100 Subject: [PATCH] Only consume the data when chaining continuations --- include/continuable/detail/core/base.hpp | 25 ++++++++++++------------ 1 file changed, 12 insertions(+), 13 deletions(-) diff --git a/include/continuable/detail/core/base.hpp b/include/continuable/detail/core/base.hpp index 915eeca..3699ba3 100644 --- a/include/continuable/detail/core/base.hpp +++ b/include/continuable/detail/core/base.hpp @@ -126,7 +126,7 @@ struct attorney { typename T, typename A, typename Continuable = continuable_base, std::decay_t>> static auto create_from(T&& continuation, A annotation, - util::ownership ownership) { + util::ownership ownership = {}) { (void)annotation; return Continuable({std::forward(continuation)}, ownership); } @@ -720,7 +720,7 @@ struct chained_continuation, HandleResults, // Invoke the continuation with a proxy callback. // The proxy callback is responsible for passing // the result to the callback as well as decorating it. - invoke_continuation(std::move(continuation_), std::move(proxy)); + util::invoke(std::move(continuation_), std::move(proxy)); } bool operator()(is_ready_arg_t) const noexcept { @@ -755,19 +755,18 @@ auto chain_continuation(Continuation&& continuation, Callback&& callback, next_hint_of(std::integral_constant{}, traits::identify{}, Hint{}); - // TODO consume only the data here so the freeze isn't needed - auto ownership_ = attorney::ownership_of(continuation); - continuation.freeze(); + auto data = + attorney::consume(std::forward(continuation).finish()); - using continuation_t = chained_continuation< - Hint, HandleResults, HandleErrors, traits::unrefcv_t, - traits::unrefcv_t, traits::unrefcv_t>; + using continuation_t = + chained_continuation, + traits::unrefcv_t>; - return attorney::create_from( - continuation_t(std::forward(continuation), - std::forward(callback), - std::forward(executor)), - next_hint, ownership_); + return attorney::create_from(continuation_t(std::move(data), + std::forward(callback), + std::forward(executor)), + next_hint); } /// Final invokes the given continuation chain: