asio 0.3.7 Home | Reference | Tutorial | Examples | Design
Reference Class Hierarchy | Class Index | Member Index

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 asio::io_service::run(). No other threads that are calling 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 asio::io_service::run() call may be restarted without the need for an intervening call to 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:
 asio::io_service io_service;
 ...
 for (;;)
 {
   try
   {
     io_service.run();
     break; // run() exited normally
   }
   catch (my_exception& e)
   {
     // Deal with exception as appropriate.
   }
 }
asio 0.3.7 Home | Reference | Tutorial | Examples | Design