summaryrefslogtreecommitdiffhomepage
path: root/compat/qcopyable-mutex.cpp
diff options
context:
space:
mode:
Diffstat (limited to 'compat/qcopyable-mutex.cpp')
-rw-r--r--compat/qcopyable-mutex.cpp36
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());
+}
+