The "SwapBackSentinel" class's destructor guarantees that FEProblemBase::swapBackMaterials{Face,Neighbor}() is called even when an exception is thrown from FEProblemBase::reinitMaterials{Face,Neighbor}. More...
#include <SwapBackSentinel.h>
Public Types | |
using | SwapBackFunction = void(FEProblemBase::*)(THREAD_ID) |
SwapBackFunction is a typedef for a pointer to an FEProblemBase member function taking a THREAD_ID and returning void. More... | |
Public Member Functions | |
SwapBackSentinel (FEProblemBase &fe_problem, SwapBackFunction func, THREAD_ID tid, const bool &predicate, const bool store_pred_as_value=true) | |
Constructor taking an FEProblemBase reference, a function to call, and the THREAD_ID argument. More... | |
SwapBackSentinel (FEProblemBase &fe_problem, SwapBackFunction func, THREAD_ID tid) | |
~SwapBackSentinel () | |
The destructor calls swap back function only if the predicate is true. More... | |
Private Attributes | |
FEProblemBase & | _fe_problem |
SwapBackFunction | _func |
THREAD_ID | _thread_id |
const bool & | _predicate |
Static Private Attributes | |
static constexpr bool | _always_true = true |
static constexpr bool | _always_false = false |
The "SwapBackSentinel" class's destructor guarantees that FEProblemBase::swapBackMaterials{Face,Neighbor}() is called even when an exception is thrown from FEProblemBase::reinitMaterials{Face,Neighbor}.
This is because stack unwinding (for caught exceptions) guarantees that object destructors are called. The typical way of using this object is to construct it in the same scope where reinitMaterials is called:
{ SwapBackSentinel sentinel(_fe_problem, &FEProblemBase::swapBackMaterials, _tid); _fe_problem.reinitMaterials(_subdomain, _tid); }
Definition at line 32 of file SwapBackSentinel.h.
using SwapBackSentinel::SwapBackFunction = void (FEProblemBase::*)(THREAD_ID) |
SwapBackFunction is a typedef for a pointer to an FEProblemBase member function taking a THREAD_ID and returning void.
All the FEProblemBase::swapBackMaterialXXX() members have this signature.
Definition at line 40 of file SwapBackSentinel.h.
|
inline |
Constructor taking an FEProblemBase reference, a function to call, and the THREAD_ID argument.
Definition at line 46 of file SwapBackSentinel.h.
|
inline |
Definition at line 58 of file SwapBackSentinel.h.
|
inline |
The destructor calls swap back function only if the predicate is true.
Definition at line 66 of file SwapBackSentinel.h.
|
staticprivate |
Definition at line 77 of file SwapBackSentinel.h.
|
staticprivate |
Definition at line 76 of file SwapBackSentinel.h.
|
private |
Definition at line 73 of file SwapBackSentinel.h.
Referenced by ~SwapBackSentinel().
|
private |
Definition at line 74 of file SwapBackSentinel.h.
Referenced by ~SwapBackSentinel().
|
private |
Definition at line 78 of file SwapBackSentinel.h.
Referenced by ~SwapBackSentinel().
|
private |
Definition at line 75 of file SwapBackSentinel.h.
Referenced by ~SwapBackSentinel().