Qt Utilities  5.6.0
Common Qt related C++ classes and routines used by my applications such as dialogs, widgets and models
adoptlocker.h
Go to the documentation of this file.
1 #ifndef THEADING_UTILS_ADOPTLOCKER_H
2 #define THEADING_UTILS_ADOPTLOCKER_H
3 
4 #include <QtGlobal>
5 
6 QT_FORWARD_DECLARE_CLASS(QMutex)
7 
8 namespace ThreadingUtils {
9 
13 template<typename Mutex = QMutex>
15 {
16 public:
20  AdoptLocker(Mutex &mutex) :
21  m_mutex(mutex)
22  {}
23 
28  {
29  m_mutex.unlock();
30  }
31 
32 private:
33  Mutex &m_mutex;
34 };
35 
36 }
37 
38 #endif // THEADING_UTILS_ADOPTLOCKER_H
AdoptLocker(Mutex &mutex)
Constructs the locker for the specified mutex.
Definition: adoptlocker.h:20
~AdoptLocker()
Unlocks the mutex specified when constructing the instance.
Definition: adoptlocker.h:27
Like QMutexLocker, but assumes that the mutex has already been locked.
Definition: adoptlocker.h:14