I was wondering what happens when an exception is thrown inside a handler function when using boost asio's run() function on the io_context from multiple threads. My thread function which calls the run operation on the io_context looks like this:
while(!io->stopped() && *stop == false) {
try {
auto cnt = io->run();
}catch(std::exception &e) {
}
if(io->stopped()) {
break;
}
}
The number of threads is 1..N. The documentation states that any subsequent calls to run() must call restart() first but restart() must not be called when there are still any active calls to run() which I can't know because there may be still threads calling run().
What is the solution for this when there is just one io_context and many threads calling run()