Fix future::then
This commit is contained in:
parent
08d71a8496
commit
8091183375
1 changed files with 4 additions and 2 deletions
|
|
@ -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;
|
||||
}
|
||||
}
|
||||
|
||||
|
|
|
|||
Loading…
Add table
Reference in a new issue