File tree Expand file tree Collapse file tree 3 files changed +30
-39
lines changed
tests/run-pass/concurrency Expand file tree Collapse file tree 3 files changed +30
-39
lines changed Load Diff This file was deleted.
Load Diff This file was deleted.
Original file line number Diff line number Diff line change @@ -312,6 +312,34 @@ fn check_rwlock_unlock_bug2() {
312
312
h. join ( ) . unwrap ( ) ;
313
313
}
314
314
315
+ fn park_timeout ( ) {
316
+ let start = Instant :: now ( ) ;
317
+
318
+ thread:: park_timeout ( Duration :: from_millis ( 200 ) ) ;
319
+ // Normally, waiting in park/park_timeout may spuriously wake up early, but we
320
+ // know Miri's timed synchronization primitives do not do that.
321
+
322
+ assert ! ( ( 200 ..500 ) . contains( & start. elapsed( ) . as_millis( ) ) ) ;
323
+ }
324
+
325
+ fn park_unpark ( ) {
326
+ let t1 = thread:: current ( ) ;
327
+ let t2 = thread:: spawn ( move || {
328
+ thread:: park ( ) ;
329
+ thread:: sleep ( Duration :: from_millis ( 200 ) ) ;
330
+ t1. unpark ( ) ;
331
+ } ) ;
332
+
333
+ let start = Instant :: now ( ) ;
334
+
335
+ t2. thread ( ) . unpark ( ) ;
336
+ thread:: park ( ) ;
337
+ // Normally, waiting in park/park_timeout may spuriously wake up early, but we
338
+ // know Miri's timed synchronization primitives do not do that.
339
+
340
+ assert ! ( ( 200 ..500 ) . contains( & start. elapsed( ) . as_millis( ) ) ) ;
341
+ }
342
+
315
343
fn main ( ) {
316
344
check_barriers ( ) ;
317
345
check_conditional_variables_notify_one ( ) ;
@@ -327,4 +355,6 @@ fn main() {
327
355
check_once ( ) ;
328
356
check_rwlock_unlock_bug1 ( ) ;
329
357
check_rwlock_unlock_bug2 ( ) ;
358
+ park_timeout ( ) ;
359
+ park_unpark ( ) ;
330
360
}
You can’t perform that action at this time.
0 commit comments