asio How to change the executor inside an awaitable?

You want to associate your executor with the completion token, and then let post/dispatch/defer figure it out from there: co_await asio::post(bind_executor(pstrand, asio::use_awaitable)); See also e.g. When must you pass io_context to boost::asio::spawn? (C++) or boost::asio::bind_executor does not execute in strand for more details on how it works/why it works/when it works. It does in fact … Read more