]> git.lizzy.rs Git - rust.git/blob - tests/pass/sleep_long.rs
make tests pass again
[rust.git] / tests / pass / sleep_long.rs
1 //@ignore-target-windows: no threads nor sleep on Windows
2 //@compile-flags: -Zmiri-ignore-leaks -Zmiri-disable-isolation
3 use std::sync::{Arc, Mutex};
4 use std::thread;
5 use std::time::Duration;
6
7 fn main() {
8     let finished = Arc::new(Mutex::new(false));
9     let t_finished = finished.clone();
10     thread::spawn(move || {
11         // Sleep very, very long.
12         thread::sleep(Duration::new(u64::MAX, 0));
13         *t_finished.lock().unwrap() = true;
14     });
15     thread::sleep(Duration::from_millis(100));
16     assert_eq!(*finished.lock().unwrap(), false);
17     // Stopping the main thread will also kill the sleeper.
18 }