@@ -28,8 +28,9 @@ fn wait_wake() {
28
28
) ;
29
29
}
30
30
} ) ;
31
- thread:: yield_now ( ) ;
32
- let mut timeout = libc:: timespec { tv_sec : 0 , tv_nsec : 400_000_000 } ;
31
+
32
+ // 10ms should be enough.
33
+ let mut timeout = libc:: timespec { tv_sec : 0 , tv_nsec : 10_000_000 } ;
33
34
let timeout_size_arg =
34
35
ptr:: without_provenance_mut :: < libc:: c_void > ( mem:: size_of :: < libc:: timespec > ( ) ) ;
35
36
unsafe {
@@ -51,13 +52,13 @@ fn wait_wake() {
51
52
}
52
53
53
54
fn wake_two_of_three ( ) {
54
- // We create 2 threads that wait on a futex with a 500ms timeout.
55
- // The main thread wakes up 1 thread waiting on this futex and after this
56
- // checks that only 1 thread woke up and the other timed out.
55
+ // We create 2 threads that wait on a futex with a 100ms timeout.
56
+ // The main thread wakes up 2 threads waiting on this futex and after this
57
+ // checks that only those threads woke up and the other one timed out.
57
58
static mut FUTEX : u32 = 0 ;
58
59
59
60
fn waiter ( ) -> bool {
60
- let mut timeout = libc:: timespec { tv_sec : 0 , tv_nsec : 500_000_000 } ;
61
+ let mut timeout = libc:: timespec { tv_sec : 0 , tv_nsec : 100_000_000 } ;
61
62
let timeout_size_arg =
62
63
ptr:: without_provenance_mut :: < libc:: c_void > ( mem:: size_of :: < libc:: timespec > ( ) ) ;
63
64
unsafe {
@@ -77,7 +78,9 @@ fn wait_wake() {
77
78
let t2 = thread:: spawn ( waiter) ;
78
79
let t3 = thread:: spawn ( waiter) ;
79
80
81
+ // Run all the waiters, so they can go to sleep.
80
82
thread:: yield_now ( ) ;
83
+
81
84
// Wake up 2 thread and make sure 1 is still waiting.
82
85
unsafe {
83
86
assert_eq ! (
0 commit comments