From 6d7679cf7c997237805022f828846164ff947a40 Mon Sep 17 00:00:00 2001 From: Stanislaw Halik Date: Tue, 24 Oct 2017 11:11:07 +0200 Subject: compat/mutex: split from header --- compat/qcopyable-mutex.hpp | 44 +++++++++++++++++--------------------------- 1 file changed, 17 insertions(+), 27 deletions(-) (limited to 'compat/qcopyable-mutex.hpp') diff --git a/compat/qcopyable-mutex.hpp b/compat/qcopyable-mutex.hpp index 57b0030d..af82876d 100644 --- a/compat/qcopyable-mutex.hpp +++ b/compat/qcopyable-mutex.hpp @@ -1,37 +1,27 @@ #pragma once -#include - -class MyMutex { -private: - QMutex inner; +#include -public: - QMutex* operator->() { return &inner; } - QMutex* operator->() const { return &const_cast(this)->inner; } +#include - MyMutex operator=(const MyMutex& datum) - { - auto mode = - datum->isRecursive() - ? QMutex::Recursive - : QMutex::NonRecursive; +#include "export.hpp" - return MyMutex(mode); - } +class OTR_COMPAT_EXPORT mutex +{ + std::unique_ptr inner; - MyMutex(const MyMutex& datum) +public: + enum mode { - *this = datum; - } + recursive = QMutex::Recursive, + normal = QMutex::NonRecursive, + }; - MyMutex(QMutex::RecursionMode mode = QMutex::NonRecursive) : - inner(mode) - { - } + mutex& operator=(const mutex& datum); + mutex(const mutex& datum); + mutex(mode m = normal); - QMutex* operator&() const - { - return const_cast(&inner); - } + QMutex* operator&() const; + operator QMutex*() const; + QMutex* operator->() const; }; -- cgit v1.2.3