Devel Lib
LockGuard.h
1 #pragma once
2 
3 #include "Core/Global.h"
4 #include "Threading/Mutex/Mutex.h"
7 namespace Devel::Threading {
12 #define RecursiveLockGuard(x) CLockGuard CatUniqueVar(locker, __COUNTER__)(x);
13 
28  class CLockGuard {
29  public:
32  CLockGuard(const CMutex &i_oMutex)
33  : m_oMutex(i_oMutex) {
34  this->m_oMutex.lock();
35  }
36 
39  this->m_oMutex.unlock();
40  }
41 
42  private:
45  const CMutex &m_oMutex;
46  };
47 }
A lock guard class for a recursive mutex.
Definition: LockGuard.h:28
~CLockGuard()
Destroys the CLockGuard and releases the lock on the mutex.
Definition: LockGuard.h:38
CLockGuard(const CMutex &i_oMutex)
Constructs a CLockGuard and acquires the lock on the specified mutex.
Definition: LockGuard.h:32
A class for handling recursive mutexes.
Definition: Mutex.h:47
void lock() const
Locks the mutex. If the mutex is currently locked by another thread, this call will block the calling...
Definition: Mutex.h:58
void unlock() const
Unlocks the mutex.
Definition: Mutex.h:63
The namespace encapsulating threading related classes and functions in the Devel framework.