summaryrefslogtreecommitdiffhomepage
path: root/compat/qcopyable-mutex.cpp
blob: 71720f17a89e387358012a8e49385b50ccdbe63e (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
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());
}