12using namespace QtFutex;
14#if defined(QATOMICWAIT_USE_FALLBACK)
15static constexpr bool ForcedFallbackAtomicWait =
true;
16namespace atomicwait = QtFallbackAtomicWait;
19namespace atomicwait =
q20;
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
102
103
104
105
106
109
110
111
112
113
114
115
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
136
137
138
139
140
141
142
143
144
145
148
149
150
151
152
153
154
155
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
180
181
182
183
185void QLatch::waitInternal(
int current)
noexcept
188 if (current & NoWaiters) {
192 if (__atomic_and_fetch(
reinterpret_cast<
int *>(&counter._q_value), ~NoWaiters,
193 int(std::memory_order_relaxed)) == 0)
200 counter.fetchAndAndRelaxed(~NoWaiters);
201 if (counter.loadRelaxed() == 0)
205 current &= ~NoWaiters;
207 auto waitLoop = [&](
auto waiter) {
210 }
while ((current = counter.loadAcquire()) != 0);
214 waitLoop([&](
int current) { futexWait(counter, current); });
216 waitLoop([&](
int current) {
217 atomicwait::atomic_wait_explicit(&counter._q_value, current, std::memory_order_relaxed);
221void QLatch::wakeUp()
noexcept
223 if (futexAvailable() && !ForcedFallbackAtomicWait)
224 futexWakeAll(counter);
226 atomicwait::atomic_notify_all(&counter._q_value);
static constexpr bool ForcedFallbackAtomicWait