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
qfutex_win_p.h
Go to the documentation of this file.
1// Copyright (C) 2023 Intel Corporation.
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 QFUTEX_WIN_P_H
6#define QFUTEX_WIN_P_H
7
8//
9// W A R N I N G
10// -------------
11//
12// This file is not part of the Qt API. It exists purely as an
13// implementation detail. This header file may change from version to
14// version without notice, or even be removed.
15//
16// We mean it.
17//
18
19#include <private/qglobal_p.h>
20#include <qdeadlinetimer.h>
21#include <qtsan_impl.h>
22
23#include <qt_windows.h>
24
25#define QT_ALWAYS_USE_FUTEX
26
28
29namespace QtWindowsFutex {
30constexpr inline bool futexAvailable() { return true; }
31
32template <typename Atomic>
33inline void futexWait(Atomic &futex, typename Atomic::Type expectedValue)
34{
36 WaitOnAddress(&futex, &expectedValue, sizeof(expectedValue), INFINITE);
38}
39template <typename Atomic>
40inline bool futexWait(Atomic &futex, typename Atomic::Type expectedValue, QDeadlineTimer deadline)
41{
42 using namespace std::chrono;
43 BOOL r = WaitOnAddress(&futex, &expectedValue, sizeof(expectedValue), DWORD(deadline.remainingTime()));
44 return r || GetLastError() != ERROR_TIMEOUT;
45}
46template <typename Atomic> inline void futexWakeAll(Atomic &futex)
47{
48 WakeByAddressAll(&futex);
49}
50template <typename Atomic> inline void futexWakeOne(Atomic &futex)
51{
52 WakeByAddressSingle(&futex);
53}
54} // namespace QtWindowsFutex
55namespace QtFutex = QtWindowsFutex;
56
57QT_END_NAMESPACE
58
59#endif // QFUTEX_WIN_P_H
void futexRelease(void *, void *=nullptr)
Definition qtsan_impl.h:75
void futexAcquire(void *, void *=nullptr)
Definition qtsan_impl.h:74
void futexWakeOne(Atomic &futex)
void futexWait(Atomic &futex, typename Atomic::Type expectedValue)
void futexWakeAll(Atomic &futex)
constexpr bool futexAvailable()
bool futexWait(Atomic &futex, typename Atomic::Type expectedValue, QDeadlineTimer deadline)