diff options
Diffstat (limited to 'compat/copyable-mutex.cpp')
-rw-r--r-- | compat/copyable-mutex.cpp | 36 |
1 files changed, 36 insertions, 0 deletions
diff --git a/compat/copyable-mutex.cpp b/compat/copyable-mutex.cpp new file mode 100644 index 00000000..7c112c5e --- /dev/null +++ b/compat/copyable-mutex.cpp @@ -0,0 +1,36 @@ +#include "copyable-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()); +} + |