
29 May
2009
29 May
'09
1:25 p.m.
J.W.F. Thirion wrote:
We're having a problem using the ASIO class with multiple IO service threads and throwing exceptions inside the handle_xxx functions, as used by the async_xxx functions of the ASIO library.
It seems that when any error is thrown in a normal/non-handler function, the try/catch block of the main program is able to catch the error. However, when the handler functions are called (I would assume by the io service, now running in a separate thread), the main function's try/catch blocks never receive the execeptions, and a std::terminate() is called automatically.
Exceptions do not cross threads. You must catch the exception in the thread it is being thrown in, that is to say the thread running the io_service.