Skip to content

Commit

Permalink
fixed memory_leak for spawning task<void>.
Browse files Browse the repository at this point in the history
  • Loading branch information
klemens-morgenstern committed Dec 13, 2024
1 parent 9410f90 commit bff49f6
Showing 1 changed file with 4 additions and 1 deletion.
5 changes: 4 additions & 1 deletion include/boost/cobalt/detail/spawn.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -144,17 +144,20 @@ struct async_initiate_spawn
executor_type exec_;
decltype(recs) r;
Handler handler;
asio::cancellation_slot sl;

void operator()()
{
if (sl.is_connected())
sl.clear();
auto ex = r->exception;
r.reset();
std::move(handler)(ex);
}
};

p->awaited_from.reset(detail::post_coroutine(completion_handler{
alloc, asio::get_associated_executor(h, exec), std::move(recs), std::forward<Handler>(h)
alloc, asio::get_associated_executor(h, exec), std::move(recs), std::forward<Handler>(h), sl
}).address());

asio::dispatch(exec, std::coroutine_handle<detail::task_promise<void>>::from_promise(*p->promise));
Expand Down

0 comments on commit bff49f6

Please sign in to comment.