Currently I'm trying to make it possible to remove work queued through post
or dispatch
to an io_context
. The work is queued by a small amount of queuer groups for which the work shall be removeable all at once:
boost::asio::io_context context;
auto work = [] {
// ...
};
boost::asio::post(context, std::move(work));
// ... now I want to remove the work
Is there such a functionality provided by the asio library?
Currently the application I'm working on, is using a thread pool which invokes io_context::run()
from multiple threads.
My idea was that I could create multiple io_context
s that are dispatched by the thread pool such that one io_context
represents a group that could be removed through io_context::stop()
. All io_context
s would be held inside a single list which is then pooled for outstanding events.
However I believe that pooling or waiting for many io_context
s could lead to performance issues.
Is there a different solution?