Reputation: 1019
In my server application there is a pool of threads calling the io_service run() function. When a handler throws an exception the run function throws that exception too. Multiple threads call the run function in a try catch block. To restart the event handler I need to call run again but the documentation stated that restart() has to be called first. Restarting the io_service must assure that all run calls has been finished. How can I do that when other threads are still calling the run function?
Upvotes: 2
Views: 307
Reputation: 394054
To restart the event handler I need to call run again but the documentation stated that restart() has to be called first.
No the documentation does not say that. You need to reset once the service had run out of work/been stopped. You did neither, so you do not need reset there.
Simply do as explained in this post Should the exception thrown by boost::asio::io_service::run() be caught? (which links to the docs)
Upvotes: 2