GetFEM++  5.3
getfem::thread_exception Class Reference

Allows to re-throw exceptions, generated in OpemMP parallel section. More...

#include <getfem_omp.h>

Public Member Functions

 ~thread_exception ()
 re-throws the first captured exception
 
template<typename Function , typename... Parameters>
void run (Function f, Parameters...params)
 Run function f in parallel part to capture it's exceptions. More...
 
std::vector< std::exception_ptr > caughtExceptions () const
 vector of pointers to caught exceptions
 

Detailed Description

Allows to re-throw exceptions, generated in OpemMP parallel section.

Collects exceptions from all threads and on destruction re-throws the first one, so that it can be again caught in the master thread.

Definition at line 348 of file getfem_omp.h.

Member Function Documentation

template<typename Function , typename... Parameters>
void getfem::thread_exception::run ( Function  f,
Parameters...  params 
)
inline

Run function f in parallel part to capture it's exceptions.

Possible syntax can be: thread_exception exception; #pragma omp parallel... { exception.run([&] { your code that can throw exceptions }); } exception.rethrow();

Definition at line 368 of file getfem_omp.h.


The documentation for this class was generated from the following files: