about summary refs log tree commit diff
path: root/src/tools/miri/tests/pass/concurrency/thread_park_isolated.rs
blob: 35145fe9bd31a81ab07605489cef10d7821d17de (plain)
1
2
3
4
5
6
7
8
9
10
11
12
//@ignore-target: apple # park_timeout on macOS uses the system clock
use std::thread;
use std::time::{Duration, Instant};

fn main() {
    let start = Instant::now();

    thread::park_timeout(Duration::from_millis(200));

    // Thanks to deterministic execution, this will wait *exactly* 200ms, plus the time for the surrounding code.
    assert!((200..210).contains(&start.elapsed().as_millis()), "{}", start.elapsed().as_millis());
}