diff options
author | Stanislaw Halik <sthalik@misaki.pl> | 2017-10-24 11:11:07 +0200 |
---|---|---|
committer | Stanislaw Halik <sthalik@misaki.pl> | 2017-10-27 16:42:58 +0200 |
commit | 6d7679cf7c997237805022f828846164ff947a40 (patch) | |
tree | bfcee7a55e18412629034ffd01d3dfd7cbade9c9 /compat/qcopyable-mutex.cpp | |
parent | 0a0000a6c4ca5ebfffd33d70f7b7963473be1471 (diff) |
compat/mutex: split from header
Diffstat (limited to 'compat/qcopyable-mutex.cpp')
-rw-r--r-- | compat/qcopyable-mutex.cpp | 36 |
1 files changed, 36 insertions, 0 deletions
diff --git a/compat/qcopyable-mutex.cpp b/compat/qcopyable-mutex.cpp new file mode 100644 index 00000000..71720f17 --- /dev/null +++ b/compat/qcopyable-mutex.cpp @@ -0,0 +1,36 @@ +#include "qcopyable-mutex.hpp" + +mutex& mutex::operator=(const mutex& datum) +{ + inner = nullptr; + inner = std::make_unique<QMutex>(datum->isRecursive() + ? QMutex::Recursive + : QMutex::NonRecursive); + return *this; +} + +mutex::mutex(const mutex& datum) +{ + *this = datum; +} + +mutex::mutex(mutex::mode m) : + inner(std::make_unique<QMutex>(static_cast<QMutex::RecursionMode>(int(m)))) +{ +} + +QMutex* mutex::operator&() const +{ + return *this; +} + +QMutex* mutex::operator->() const +{ + return *this; +} + +mutex::operator QMutex*() const +{ + return const_cast<QMutex*>(inner.get()); +} + |