Skip to content

Commit 42523d9

Browse files
committed
make a sync test more reliable
1 parent dfa6f88 commit 42523d9

File tree

1 file changed

+2
-3
lines changed

1 file changed

+2
-3
lines changed

tests/pass/concurrency/sync.rs

Lines changed: 2 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -77,13 +77,12 @@ fn check_conditional_variables_timed_wait_notimeout() {
7777
let guard = lock.lock().unwrap();
7878

7979
let handle = thread::spawn(move || {
80+
thread::sleep(Duration::from_millis(100)); // Make sure the other thread is waiting by the time we call `notify`.
8081
let (_lock, cvar) = &*pair2;
8182
cvar.notify_one();
8283
});
8384

84-
// macOS runners are very unreliable.
85-
let timeout = if cfg!(target_os = "macos") { 2000 } else { 500 };
86-
let (_guard, timeout) = cvar.wait_timeout(guard, Duration::from_millis(timeout)).unwrap();
85+
let (_guard, timeout) = cvar.wait_timeout(guard, Duration::from_millis(500)).unwrap();
8786
assert!(!timeout.timed_out());
8887
handle.join().unwrap();
8988
}

0 commit comments

Comments
 (0)