]> git.lyx.org Git - lyx.git/blob - src/support/mutex.cpp
Yet another deprecation fix (this is the last one I am aware of)
[lyx.git] / src / support / mutex.cpp
1 /**
2  * \file mutex.cpp
3  * This file is part of LyX, the document processor.
4  * Licence details can be found in the file COPYING.
5  *
6  * \author Peter Kümmel
7  *
8  * Full author contact details are available in file CREDITS.
9  */
10
11 #include <config.h>
12
13 #include "mutex.h"
14
15 #include <QMutex>
16
17
18 namespace lyx {
19
20
21 struct Mutex::Private
22 {
23         // QMutex::Recursive: less risks for dead-locks
24         Private() : qmutex_(QMutex::Recursive)
25         {
26         }
27
28         QMutex qmutex_;
29 };
30
31
32 Mutex::Mutex() : d(new Private)
33 {
34 }
35
36
37 Mutex::~Mutex()
38 {
39         delete d;
40 }
41
42
43 Mutex::Locker::Locker(Mutex* mtx) : mutex_(mtx)
44 {
45         mutex_->d->qmutex_.lock();
46 }
47
48
49 Mutex::Locker::~Locker()
50 {
51         mutex_->d->qmutex_.unlock();
52 }
53
54
55
56 } // namespace lyx