Boost Users :
Subject: Re: [Boost-users] Problem with throwing exceptions in async handler functions of ASIO library
From: Mathias Gaunard (mathias.gaunard_at_[hidden])
Date: 2009-05-29 09:25:59
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.
Boost-users list run by williamkempf at hotmail.com, kalb at libertysoft.com, bjorn.karlsson at readsoft.com, gregod at cs.rpi.edu, wekempf at cox.net