diff options
Diffstat (limited to 'compat/qcopyable-mutex.hpp')
-rw-r--r-- | compat/qcopyable-mutex.hpp | 44 |
1 files changed, 17 insertions, 27 deletions
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 <QMutex> - -class MyMutex { -private: - QMutex inner; +#include <memory> -public: - QMutex* operator->() { return &inner; } - QMutex* operator->() const { return &const_cast<MyMutex*>(this)->inner; } +#include <QMutex> - 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<QMutex> 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<QMutex*>(&inner); - } + QMutex* operator&() const; + operator QMutex*() const; + QMutex* operator->() const; }; |