Qt
Internal/Contributor docs for the Qt SDK. Note: These are NOT official API docs; those are found at https://doc.qt.io/
Loading...
Searching...
No Matches
qwaitcondition.h
Go to the documentation of this file.
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// Qt-Security score:significant reason:default
4
5#ifndef QWAITCONDITION_H
6#define QWAITCONDITION_H
7
8#include <QtCore/QDeadlineTimer>
9
10QT_BEGIN_NAMESPACE
11
12#if QT_CONFIG(thread)
13
14class QWaitConditionPrivate;
15class QMutex;
16class QReadWriteLock;
17
18class Q_CORE_EXPORT QWaitCondition
19{
20public:
21 QWaitCondition();
22 ~QWaitCondition();
23
24 bool wait(QMutex *lockedMutex,
25 QDeadlineTimer deadline = QDeadlineTimer(QDeadlineTimer::Forever));
26 bool wait(QMutex *lockedMutex, unsigned long time);
27
28 bool wait(QReadWriteLock *lockedReadWriteLock,
29 QDeadlineTimer deadline = QDeadlineTimer(QDeadlineTimer::Forever));
30 bool wait(QReadWriteLock *lockedReadWriteLock, unsigned long time);
31
32 void wakeOne();
33 void wakeAll();
34
35 void notify_one() { wakeOne(); }
36 void notify_all() { wakeAll(); }
37
38private:
39 Q_DISABLE_COPY(QWaitCondition)
40
41 QWaitConditionPrivate *d;
42};
43
44#else
45
46class QMutex;
47class QReadWriteLock;
48
49class Q_CORE_EXPORT QWaitCondition
50{
51public:
52 QWaitCondition() {}
53 ~QWaitCondition() {}
54
55 bool wait(QMutex *, QDeadlineTimer = QDeadlineTimer(QDeadlineTimer::Forever))
56 { return true; }
57 bool wait(QReadWriteLock *, QDeadlineTimer = QDeadlineTimer(QDeadlineTimer::Forever))
58 { return true; }
59 bool wait(QMutex *, unsigned long) { return true; }
60 bool wait(QReadWriteLock *, unsigned long) { return true; }
61
62 void wakeOne() {}
63 void wakeAll() {}
64
65 void notify_one() { wakeOne(); }
66 void notify_all() { wakeAll(); }
67};
68
69#endif // QT_CONFIG(thread)
70
71QT_END_NAMESPACE
72
73#endif // QWAITCONDITION_H
bool wait(QDeadlineTimer deadline)
int wait_relative(QDeadlineTimer deadline)
static void qt_initialize_pthread_cond(pthread_cond_t *cond, const char *where)
static QT_BEGIN_NAMESPACE void qt_report_pthread_error(int code, const char *where, const char *what)