Celeritas
0.5.0-56+6b053cd
|
Temporarily store exception pointers. More...
#include <MultiExceptionHandler.hh>
Public Types | |
Type aliases | |
using | VecExceptionPtr = std::vector< std::exception_ptr > |
Public Member Functions | |
CELER_DEFAULT_COPY_MOVE (MultiExceptionHandler) | |
~MultiExceptionHandler () | |
Terminate if destroyed without handling exceptions. | |
void | operator() (std::exception_ptr p) |
Thread-safe capture of the given exception. | |
bool | empty () const |
Whether no exceptions have been stored (not thread safe) | |
VecExceptionPtr | release () |
Release exceptions for someone else to process (not thread safe) | |
Temporarily store exception pointers.
This is useful for storing multiple exceptions in unrelated loops (where one exception shouldn't affect the program flow outside of the scope), especially for OpenMP parallel execution, where exceptions cannot be propagated.
critical
mutex, not a std
mutex. If using this class in a std::thread
context, wrap the call operator in a lambda with a std::scoped_lock
. We could refactor as a CRTP class with a protected push_back
function that lets us specialize the mutex implementation.