19#include <qdeadlinetimer.h>
20#include <qtsan_impl.h>
21#include <private/qglobal_p.h>
23#include <os/os_sync_wait_on_address.h>
25#define QT_ALWAYS_USE_FUTEX
33template <
typename Atomic>
34inline void futexWait(Atomic &futex,
typename Atomic::Type expectedValue)
37 static_assert(
sizeof(
typename Atomic::Type) == 4 ||
sizeof(
typename Atomic::Type) == 8);
38 os_sync_wait_on_address(&futex, quint64(expectedValue),
sizeof(
typename Atomic::Type),
39 OS_SYNC_WAIT_ON_ADDRESS_NONE);
43template <
typename Atomic>
44inline bool futexWait(Atomic &futex,
typename Atomic::Type expectedValue, QDeadlineTimer timer)
47 static_assert(
sizeof(
typename Atomic::Type) == 4 ||
sizeof(
typename Atomic::Type) == 8);
48 int r = os_sync_wait_on_address_with_timeout(
49 &futex, quint64(expectedValue),
sizeof(
typename Atomic::Type),
50 OS_SYNC_WAIT_ON_ADDRESS_NONE, OS_CLOCK_MACH_ABSOLUTE_TIME, timer.remainingTimeNSecs());
52 return r >= 0 || errno != ETIMEDOUT;
55template <
typename Atomic>
58 static_assert(
sizeof(
typename Atomic::Type) == 4 ||
sizeof(
typename Atomic::Type) == 8);
59 os_sync_wake_by_address_all(&futex,
sizeof(
typename Atomic::Type),
60 OS_SYNC_WAKE_BY_ADDRESS_NONE);
63template <
typename Atomic>
66 static_assert(
sizeof(
typename Atomic::Type) == 4 ||
sizeof(
typename Atomic::Type) == 8);
67 os_sync_wake_by_address_any(&futex,
sizeof(
typename Atomic::Type),
68 OS_SYNC_WAKE_BY_ADDRESS_NONE);
Combined button and popup list for selecting options.
constexpr bool futexAvailable()
void futexWakeOne(Atomic &futex)
void futexWait(Atomic &futex, typename Atomic::Type expectedValue)
void futexWakeAll(Atomic &futex)
bool futexWait(Atomic &futex, typename Atomic::Type expectedValue, QDeadlineTimer timer)
void futexRelease(void *, void *=nullptr)
void futexAcquire(void *, void *=nullptr)