summaryrefslogtreecommitdiffhomepage
path: root/compat/copyable-mutex.cpp
diff options
context:
space:
mode:
authorStanislaw Halik <sthalik@misaki.pl>2017-10-24 11:30:35 +0200
committerStanislaw Halik <sthalik@misaki.pl>2017-10-27 16:42:58 +0200
commitb15fe980671e028d0849e11878e0edf9a88669a5 (patch)
tree221cbd9964ff52e3ce85f1fda21d075d3f14b88d /compat/copyable-mutex.cpp
parent6d7679cf7c997237805022f828846164ff947a40 (diff)
compat/mutex: rename
Diffstat (limited to 'compat/copyable-mutex.cpp')
-rw-r--r--compat/copyable-mutex.cpp36
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());
+}
+