From 80911833755e66ec023b44de51ccdc120ec9396f Mon Sep 17 00:00:00 2001 From: lisyarus Date: Thu, 4 Mar 2021 20:30:02 +0300 Subject: [PATCH] Fix future::then --- libs/async/include/psemek/async/future.hpp | 6 ++++-- 1 file changed, 4 insertions(+), 2 deletions(-) diff --git a/libs/async/include/psemek/async/future.hpp b/libs/async/include/psemek/async/future.hpp index e3a36fa9..d33d9139 100644 --- a/libs/async/include/psemek/async/future.hpp +++ b/libs/async/include/psemek/async/future.hpp @@ -428,19 +428,21 @@ namespace psemek::async { using R = decltype(f()); packaged_task t(std::forward(f)); + auto fut = t.get_future(); std::lock_guard lock{state_->then_mutex}; state_->then_func = std::move(t); - return t.get_future(); + return fut; } else { using R = decltype(f(*(state_->value))); packaged_task t(std::forward(f)); + auto fut = t.get_future(); std::lock_guard lock{state_->then_mutex}; state_->then_func = std::move(t); - return t.get_future(); + return fut; } }