mirror of
https://github.com/rust-lang/rust.git
synced 2026-05-29 20:46:07 +03:00
make a sync test more reliable
This commit is contained in:
@@ -77,13 +77,12 @@ fn check_conditional_variables_timed_wait_notimeout() {
|
||||
let guard = lock.lock().unwrap();
|
||||
|
||||
let handle = thread::spawn(move || {
|
||||
thread::sleep(Duration::from_millis(100)); // Make sure the other thread is waiting by the time we call `notify`.
|
||||
let (_lock, cvar) = &*pair2;
|
||||
cvar.notify_one();
|
||||
});
|
||||
|
||||
// macOS runners are very unreliable.
|
||||
let timeout = if cfg!(target_os = "macos") { 2000 } else { 500 };
|
||||
let (_guard, timeout) = cvar.wait_timeout(guard, Duration::from_millis(timeout)).unwrap();
|
||||
let (_guard, timeout) = cvar.wait_timeout(guard, Duration::from_millis(500)).unwrap();
|
||||
assert!(!timeout.timed_out());
|
||||
handle.join().unwrap();
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user