Workspace 6.21.5
Public Member Functions | List of all members
ScopeGuard< Callable > Class Template Reference

Generic scopeguard to simplify RAII where cleanup is needed. More...

#include <Workspace/Application/LanguageUtils/scopeguard.h>

Public Member Functions

 ScopeGuard ()=delete
 
 ScopeGuard (Callable rollback)
 
 ScopeGuard (const ScopeGuard &)=delete
 
 ScopeGuard (ScopeGuard &&rhs)
 
 ~ScopeGuard ()
 
void dismiss () noexcept
 
ScopeGuardoperator= (const ScopeGuard &)=delete
 

Detailed Description

template<typename Callable>
class CSIRO::Application::ScopeGuard< Callable >

See presentation by Andrei Alexandrescu here: https://channel9.msdn.com/Shows/Going+Deep/C-and-Beyond-2012-Andrei-Alexandrescu-Systematic-Error-Handling-in-C

Constructor & Destructor Documentation

◆ ScopeGuard() [1/4]

ScopeGuard ( Callable  rollback)
inline
Parameters
rollbackCallable to invoke when the guard is destroyed.

Creates a ScopeGuard that invokes the specified Callable object when it is destroyed if it is active at the time of destruction. To deactivate it, invoke the dismiss() function.

Note
The rollback function must not throw an exception, or it will result in the application terminating due to problems with destructor unwinding. Handle all exceptions within the rollback function.

◆ ScopeGuard() [2/4]

ScopeGuard ( ScopeGuard< Callable > &&  rhs)
inline

◆ ScopeGuard() [3/4]

ScopeGuard ( )
delete

◆ ScopeGuard() [4/4]

ScopeGuard ( const ScopeGuard< Callable > &  )
delete

◆ ~ScopeGuard()

~ScopeGuard ( )
inline

Member Function Documentation

◆ dismiss()

void dismiss ( )
inlinenoexcept

Indicate that we no longer wish to invoke the rollback function.

◆ operator=()

ScopeGuard & operator= ( const ScopeGuard< Callable > &  )
delete