oneAPI Threading Building Blocks 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 TBB run-time and handled as follows:
If the cancellation group for the task has already been cancelled, the exception is ignored.
Otherwise the exception or an approximation of it is captured and the group is cancelled.
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:
task_group_contextwas created in a translation unit compiled with
The TBB library was built with a compiler that supports the
std::exception_ptrfeature of C++11.
Otherwise an approximation of the original exception x is captured as follows:
tbb_exception, it is captured by
std::exception, it is captured as a
xis captured as a
tbb::captured_exceptionwith implementation-specified value for