| Home | Libraries | People | FAQ | More

# Effect of exceptions thrown from handlers

If an exception is thrown from a handler, the exception is allowed to propagate through the throwing thread's invocation of boost::asio::io_service::run(). No other threads that are calling boost::asio::io_service::run() are affected. It is then the responsibility of the application to catch the exception.

After the exception has been caught, the boost::asio::io_service::run() call may be restarted without the need for an intervening call to boost::asio::io_service::reset(). This allows the thread to rejoin the io_service's thread pool without impacting any other threads in the pool.

Example:

       boost::asio::io_service io_service;
       ...
       for (;;)
       {
         try
         {
           io_service.run();
           break; // run() exited normally
         }
         catch (my_exception& e)
         {
           // Deal with exception as appropriate.
         }
       }

| Copyright © 2003 - 2006 Christopher M. Kohlhoff