diff options
author | Stanislaw Halik <sthalik@misaki.pl> | 2014-10-19 16:08:46 +0200 |
---|---|---|
committer | Stanislaw Halik <sthalik@misaki.pl> | 2014-10-19 18:28:08 +0200 |
commit | dd87370ff2818ee3c3d67ba104405b85ee44daba (patch) | |
tree | d5ebdf22aaccd0e345ce7a7c2ecb7b7193ea0791 /opentrack/qcopyable-mutex.hpp | |
parent | 7e2e341c45b86f76e08d74e056929ad76ff1a383 (diff) |
decruft more
Diffstat (limited to 'opentrack/qcopyable-mutex.hpp')
-rw-r--r-- | opentrack/qcopyable-mutex.hpp | 37 |
1 files changed, 37 insertions, 0 deletions
diff --git a/opentrack/qcopyable-mutex.hpp b/opentrack/qcopyable-mutex.hpp new file mode 100644 index 00000000..f7f36f93 --- /dev/null +++ b/opentrack/qcopyable-mutex.hpp @@ -0,0 +1,37 @@ +#pragma once + +#include <QMutex> + +class MyMutex { +private: + QMutex inner; + +public: + QMutex* operator->() { return &inner; } + QMutex* operator->() const { return &const_cast<MyMutex*>(this)->inner; } + + MyMutex operator=(const MyMutex& datum) + { + auto mode = + datum->isRecursive() + ? QMutex::Recursive + : QMutex::NonRecursive; + + return MyMutex(mode); + } + + MyMutex(const MyMutex& datum) + { + *this = datum; + } + + MyMutex(QMutex::RecursionMode mode = QMutex::NonRecursive) : + inner(mode) + { + } + + QMutex* operator&() + { + return &inner; + } +}; |