Xyris  0.5
RAII.hpp File Reference
#include "Mutex.hpp"
+ Include dependency graph for RAII.hpp:
+ This graph shows which files directly or indirectly include this file:

Go to the source code of this file.

Data Structures

class  RAIIMutex
 

Functions

template<typename Function >
void lockedRegion (Function lockedWork, Mutex &mutex)
 

Detailed Description

Resource Acquisition Is Initialization mutex. Locks when constructed and unlocks when destructed.

Author
Keeton Feavel (keeto.nosp@m.n@xy.nosp@m.r.is)
Version
0.1
Date
2022-01-26

Definition in file RAII.hpp.

Function Documentation

◆ lockedRegion()

template<typename Function >
void lockedRegion ( Function  lockedWork,
Mutex mutex 
)

Mutex protected region lambda function. Executed the provided function after locking the provided mutex. Unlocks before returning. Provided lambda function cannot return any value, but may return at any point safely.

Template Parameters
FunctionLambda function template
Parameters
lockedWorkFunction to be executed in a safe manner
mutexMutex to lock before lambda execution

Definition at line 55 of file RAII.hpp.

56 {
57  RAIIMutex raiiMutex(mutex);
58  lockedWork();
59 }
RAIIMutex
Definition: RAII.hpp:16