It looks like experimental::channel functions don't support the type-erased any_completion_handler. Minimal reproducible example:
#include <boost/asio/any_completion_handler.hpp>
#include <boost/asio/experimental/channel.hpp>
using boost::system::error_code;
using boost::asio::experimental::channel;
using boost::asio::any_completion_handler;
void erased_fn(
channel<void(error_code)>& chan,
any_completion_handler<void(error_code)> h
)
{
chan.async_receive(std::move(h));
}
Having a look at the code, the problem seems that channel functions require posting to the passed I/O executor (as in calling asio::require(ex, asio::execution::blocking.never). However, the executor associated to any_completion_handler is any_completion_executor, which doesn't support posting (as opposed to any_io_executor).
Use case: I'm using any_completion_handler in Boost.MySQL to reduce compile times. I'm implementing connection pooling in terms of channels, and just found this.
If you can provide me some guidance on how to fix this, I could try to submit a PR.
Hi,
It looks like
experimental::channel
functions don't support the type-erasedany_completion_handler
. Minimal reproducible example:Or, in compiler-explorer.
Having a look at the code, the problem seems that channel functions require posting to the passed I/O executor (as in calling
asio::require(ex, asio::execution::blocking.never)
. However, the executor associated toany_completion_handler
isany_completion_executor
, which doesn't support posting (as opposed toany_io_executor
).Snippet from
any_completion_handler
:Use case: I'm using
any_completion_handler
in Boost.MySQL to reduce compile times. I'm implementing connection pooling in terms of channels, and just found this.If you can provide me some guidance on how to fix this, I could try to submit a PR.
Many thanks, Ruben.