Catching and Rethrowing Exceptions
Exceptions produced while executing a runnable’s task are captured by the runnable for later recovery. Any of these exceptions can be rethrown by any thread that has access to the runnable object. This operation is implemented by the following function:
*void RWRunnable::raise(void) const
A runnable catches any exception that propagates out of its run() member function. This includes any exceptions produced by functions invoked as functors within the runnable. When a runnable catches an exception, it:
1. Makes an internal copy of the exception.
2. Sets the execution state to RW_THR_EXCEPTION[5].
3. Sets the completion state to RW_THR_FAILED{3}.
4. Sets the execution state to RW_THR_INITIAL[6].
5. Ceases execution by returning from start() or exiting the thread.
Any exception caught by the runnable can then be recovered by rethrowing the exception using the RWRunnable::raise() function. If no exception has occurred, this function returns without doing anything.