Devel Lib
Mutex.h
1 #pragma once
2 
3 #include <mutex>
4 
7 namespace Devel::Threading {
47  class CMutex {
48  public:
50  CMutex() = default;
51 
53  virtual ~CMutex() = default;
54 
55  public:
58  void lock() const {
59  return this->m_oMutex.lock();
60  }
61 
63  void unlock() const {
64 
65  return this->m_oMutex.unlock();
66  }
67 
72  bool tryLock() const {
73  return this->m_oMutex.try_lock();
74  }
75 
76  private:
79  mutable std::recursive_mutex m_oMutex;
80  };
81 }
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
CMutex()=default
Default constructor for CMutex.
void unlock() const
Unlocks the mutex.
Definition: Mutex.h:63
bool tryLock() const
Attempts to lock the mutex. If the mutex is not available for locking, this function returns immediat...
Definition: Mutex.h:72
virtual ~CMutex()=default
Default virtual destructor for CMutex.
The namespace encapsulating threading related classes and functions in the Devel framework.