1// qmutex.sip generated by MetaSIP
2//
3// This file is part of the QtCore Python extension module.
4//
5// Copyright (c) 2021 Riverbank Computing Limited <info@riverbankcomputing.com>
6//
7// This file is part of PyQt5.
8//
9// This file may be used under the terms of the GNU General Public License
10// version 3.0 as published by the Free Software Foundation and appearing in
11// the file LICENSE included in the packaging of this file.  Please review the
12// following information to ensure the GNU General Public License version 3.0
13// requirements will be met: http://www.gnu.org/copyleft/gpl.html.
14//
15// If you do not wish to use this file under the terms of the GPL version 3.0
16// then you may purchase a commercial license.  For more information contact
17// info@riverbankcomputing.com.
18//
19// This file is provided AS IS with NO WARRANTY OF ANY KIND, INCLUDING THE
20// WARRANTY OF DESIGN, MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE.
21
22
23class QMutexLocker
24{
25%TypeHeaderCode
26#include <qmutex.h>
27%End
28
29public:
30    explicit QMutexLocker(QMutex *m) /ReleaseGIL/;
31%If (Qt_5_14_0 -)
32    explicit QMutexLocker(QRecursiveMutex *m) /ReleaseGIL/;
33%End
34    ~QMutexLocker();
35    void unlock();
36    void relock() /ReleaseGIL/;
37    QMutex *mutex() const;
38    SIP_PYOBJECT __enter__();
39%MethodCode
40        // Just return a reference to self.
41        sipRes = sipSelf;
42        Py_INCREF(sipRes);
43%End
44
45    void __exit__(SIP_PYOBJECT type, SIP_PYOBJECT value, SIP_PYOBJECT traceback);
46%MethodCode
47        sipCpp->unlock();
48%End
49
50private:
51    QMutexLocker(const QMutexLocker &);
52};
53
54class QMutex
55{
56%TypeHeaderCode
57#include <qmutex.h>
58%End
59
60public:
61    enum RecursionMode
62    {
63        NonRecursive,
64        Recursive,
65    };
66
67    explicit QMutex(QMutex::RecursionMode mode = QMutex::NonRecursive);
68    ~QMutex();
69    void lock() /ReleaseGIL/;
70    bool tryLock(int timeout = 0) /ReleaseGIL/;
71    void unlock() /ReleaseGIL/;
72%If (Qt_5_7_0 -)
73    bool isRecursive() const;
74%End
75%If (- Qt_5_7_0)
76// Methods implemented in QBasicMutex.
77bool isRecursive();
78%End
79
80private:
81    QMutex(const QMutex &);
82};
83
84%If (Qt_5_14_0 -)
85
86class QRecursiveMutex : private QMutex /NoDefaultCtors/
87{
88%TypeHeaderCode
89#include <qmutex.h>
90%End
91
92public:
93    QRecursiveMutex();
94    ~QRecursiveMutex();
95};
96
97%End
98