Fix future::then

This commit is contained in:
Nikita Lisitsa 2021-03-04 20:30:02 +03:00
parent 08d71a8496
commit 8091183375

View file

@ -428,19 +428,21 @@ namespace psemek::async
{
using R = decltype(f());
packaged_task<R()> t(std::forward<F>(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<R(T &)> t(std::forward<F>(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;
}
}