Commit bc8e0170 authored by Xavier Thompson's avatar Xavier Thompson

typon.hpp: Ensure forked task destructors are called ASAP

parent ce39a9ce
...@@ -16,7 +16,10 @@ namespace typon ...@@ -16,7 +16,10 @@ namespace typon
template <typename Task> template <typename Task>
Fork<typename Task::promise_type::value_type> fork(Task task) Fork<typename Task::promise_type::value_type> fork(Task task)
{ {
co_return co_await std::move(task); // Put the task in a local variable to ensure its destructor will
// be called on co_return instead of only on coroutine destruction.
Task local_task = std::move(task);
co_return co_await std::move(local_task);
} }
} }
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment