1// Copyright (C) 2016 The Qt Company Ltd.
2// SPDX-License-Identifier: LicenseRef-Qt-Commercial OR LGPL-3.0-only OR GPL-2.0-only OR GPL-3.0-only
3
4#ifndef QWAITCONDITION_H
5#define QWAITCONDITION_H
6
7#include <QtCore/QDeadlineTimer>
8
9QT_BEGIN_NAMESPACE
10
11#if QT_CONFIG(thread)
12
13class QWaitConditionPrivate;
14class QMutex;
15class QReadWriteLock;
16
17class Q_CORE_EXPORT QWaitCondition
18{
19public:
20 QWaitCondition();
21 ~QWaitCondition();
22
23 bool wait(QMutex *lockedMutex,
24 QDeadlineTimer deadline = QDeadlineTimer(QDeadlineTimer::Forever));
25 bool wait(QMutex *lockedMutex, unsigned long time);
26
27 bool wait(QReadWriteLock *lockedReadWriteLock,
28 QDeadlineTimer deadline = QDeadlineTimer(QDeadlineTimer::Forever));
29 bool wait(QReadWriteLock *lockedReadWriteLock, unsigned long time);
30
31 void wakeOne();
32 void wakeAll();
33
34 void notify_one() { wakeOne(); }
35 void notify_all() { wakeAll(); }
36
37private:
38 Q_DISABLE_COPY(QWaitCondition)
39
40 QWaitConditionPrivate *d;
41};
42
43#else
44
45class QMutex;
46class QReadWriteLock;
47
48class Q_CORE_EXPORT QWaitCondition
49{
50public:
51 QWaitCondition() {}
52 ~QWaitCondition() {}
53
54 bool wait(QMutex *, QDeadlineTimer = QDeadlineTimer(QDeadlineTimer::Forever))
55 { return true; }
56 bool wait(QReadWriteLock *, QDeadlineTimer = QDeadlineTimer(QDeadlineTimer::Forever))
57 { return true; }
58 bool wait(QMutex *, unsigned long) { return true; }
59 bool wait(QReadWriteLock *, unsigned long) { return true; }
60
61 void wakeOne() {}
62 void wakeAll() {}
63
64 void notify_one() { wakeOne(); }
65 void notify_all() { wakeAll(); }
66};
67
68#endif // QT_CONFIG(thread)
69
70QT_END_NAMESPACE
71
72#endif // QWAITCONDITION_H
73

source code of qtbase/src/corelib/thread/qwaitcondition.h