rust/library/std/tests/thread.rs

Ignoring revisions in .git-blame-ignore-revs. Click here to bypass and see the normal blame view.

17 lines
456 B
Rust
Raw Normal View History

2016-06-19 08:58:40 -05:00
use std::sync::{Arc, Mutex};
use std::thread;
use std::time::Duration;
2016-06-19 08:58:40 -05:00
#[test]
#[cfg_attr(target_os = "emscripten", ignore)]
fn sleep() {
2016-06-19 08:58:40 -05:00
let finished = Arc::new(Mutex::new(false));
let t_finished = finished.clone();
thread::spawn(move || {
thread::sleep(Duration::new(u64::MAX, 0));
2016-06-19 08:58:40 -05:00
*t_finished.lock().unwrap() = true;
});
thread::sleep(Duration::from_millis(100));
2016-06-19 08:58:40 -05:00
assert_eq!(*finished.lock().unwrap(), false);
}