I read in this SO answer that there are locks around several parts of asio's internals.
In addition I'm aware that asio is designed to allow multiple threads to service a single io_context.
However, if I only have a single thread servicing a single io_context, but I want to have more than 1 io_context in my application, is it safe to disable threads (per BOOST_ASIO_DISABLE_THREADS)
That is: I have one io_context and one thread which has entered its io_context::run() loop, and it is servicing a number of sockets etc. All interaction with these sockets are done within the context of that thread.
I then also have another thread, and another io_context, and that thread services that io_context and its sockets etc.
Inter-thread communication is achieved using a custom thread-safe queue and an eventfd wrapped with an asio::posix::stream_descriptor which is written to by the initiating thread, and read from the receiving thread which then pops items off the thread-safe queue.
So at no point will there be user code which attempts to call asio functions from a thread which isn't associated with the io_context servicing its asio objects.
With the above use-case in mind, is it safe to disable threads in asio?