Exceptions

Intel® Threading Building Blocks (Intel® TBB) propagates exceptions along logical paths in a tree of tasks. Because these paths cross between thread stacks, support for moving an exception between stacks is necessary.

When an exception is thrown out of a task, it is caught inside the Intel® TBB run-time and handled as follows:

  1. If the cancellation group for the task has already been cancelled, the exception is ignored.
  2. Otherwise the exception or an approximation of it is captured and the group is cancelled.
  3. The captured exception is rethrown from the root of the cancellation group after all tasks in the group have completed or have been successfully cancelled.

The exact exception is captured when both of the following conditions are true:

Otherwise an appoximation of the original exception x is captured as follows:

  1. If x is a tbb_exception, it is captured by x.move().
  2. If x is a std::exception, it is captured as a tbb::captured_exception(typeid(x).name(),x.what()).
  3. Otherwise x is captured as a tbb::captured exception with implementation-specified value for name() and what().