31 constexpr explicit QLatch(
int expected)
noexcept
32 : counter(expected | NoWaiters)
35 int pending()
const noexcept
37 return (counter.loadAcquire() & CounterMask);
40 void countDown(
int n = 1)
noexcept
42 QtTsan::latchCountDown(&counter);
43 if (counter.fetchAndSubRelease(n) == n)
47 bool tryWait()
const noexcept
51 QtTsan::latchWait(&counter);
57 if (
int current = counter.loadAcquire(); (current & CounterMask) != 0) {
58 waitInternal(current);
59 QtTsan::latchWait(&counter);
63 void arriveAndWait(
int n = 1)
noexcept
70 static constexpr int max()
noexcept {
return std::numeric_limits<
int>::max(); }
71 void count_down(
int n = 1)
noexcept { countDown(n); }
72 bool try_wait()
const noexcept {
return tryWait(); }
73 void arrive_and_wait(
int n = 1)
noexcept { arriveAndWait(n); }
76 static constexpr int NoWaitersBit = 31;
77 static constexpr int NoWaiters = 1 << NoWaitersBit;
78 static constexpr int CounterMask = ~NoWaiters;
79 QBasicAtomicInt counter;
81 Q_DISABLE_COPY_MOVE(QLatch)
83#ifdef QATOMICWAIT_USE_FALLBACK
84# define Q_LATCH_EXPORT
86# define Q_LATCH_EXPORT Q_CORE_EXPORT