asio
asio copied to clipboard
Added error_as_deferred.
Heya Chris,
I had an idea: make error_code
& exception_ptr
completion tokens, so that the following is legal:
asio::steady_timer tim{co_await asio::this_coro::executor};
asio::error_code ec;
co_await tim.async_wait(ec);
This would make this much more intuitive because it looks like the sync APIs.
I think the usefulness of this feature is more evident in the context of awaitable operators, for example, this is a code snipet in my project
boost::system::error_code ec1, ec2;
co_await (
conn->async_run(ep, {}, net::redirect_error(net::use_awaitable, ec1)) &&
conn->async_exec(req, adapt(), net::redirect_error(net::use_awaitable, ec2))
);
which is annoyingly verbose. I would have prefered to write
boost::system::error_code ec1, ec2;
co_await (conn->async_run(ep, {}, ec1) && conn->async_exec(req, adapt(), ec2));