File tree Expand file tree Collapse file tree 1 file changed +48
-0
lines changed
tests/run-pass/concurrency Expand file tree Collapse file tree 1 file changed +48
-0
lines changed Original file line number Diff line number Diff line change @@ -160,11 +160,59 @@ fn wait_wake() {
160
160
assert ! ( ( 200 ..1000 ) . contains( & start. elapsed( ) . as_millis( ) ) ) ;
161
161
}
162
162
163
+ fn wait_wake_bitset ( ) {
164
+ let start = Instant :: now ( ) ;
165
+
166
+ static FUTEX : i32 = 0 ;
167
+
168
+ thread:: spawn ( move || {
169
+ thread:: sleep ( Duration :: from_millis ( 200 ) ) ;
170
+ unsafe {
171
+ assert_eq ! ( libc:: syscall(
172
+ libc:: SYS_futex ,
173
+ & FUTEX as * const i32 ,
174
+ libc:: FUTEX_WAKE_BITSET ,
175
+ 10 , // Wake up at most 10 threads.
176
+ 0 ,
177
+ 0 ,
178
+ 0b1001 , // bitset
179
+ ) , 0 ) ; // Didn't match any thread.
180
+ }
181
+ thread:: sleep ( Duration :: from_millis ( 200 ) ) ;
182
+ unsafe {
183
+ assert_eq ! ( libc:: syscall(
184
+ libc:: SYS_futex ,
185
+ & FUTEX as * const i32 ,
186
+ libc:: FUTEX_WAKE_BITSET ,
187
+ 10 , // Wake up at most 10 threads.
188
+ 0 ,
189
+ 0 ,
190
+ 0b0110 , // bitset
191
+ ) , 1 ) ; // Woken up one thread.
192
+ }
193
+ } ) ;
194
+
195
+ unsafe {
196
+ assert_eq ! ( libc:: syscall(
197
+ libc:: SYS_futex ,
198
+ & FUTEX as * const i32 ,
199
+ libc:: FUTEX_WAIT_BITSET ,
200
+ 0 ,
201
+ ptr:: null:: <libc:: timespec>( ) ,
202
+ 0 ,
203
+ 0b0100 , // bitset
204
+ ) , 0 ) ;
205
+ }
206
+
207
+ assert ! ( ( 400 ..1000 ) . contains( & start. elapsed( ) . as_millis( ) ) ) ;
208
+ }
209
+
163
210
fn main ( ) {
164
211
wake_nobody ( ) ;
165
212
wake_dangling ( ) ;
166
213
wait_wrong_val ( ) ;
167
214
wait_timeout ( ) ;
168
215
wait_absolute_timeout ( ) ;
169
216
wait_wake ( ) ;
217
+ wait_wake_bitset ( ) ;
170
218
}
You can’t perform that action at this time.
0 commit comments