use std::thread;
use std::time::Duration;
#[inline]
pub(crate) fn park_thread() {
thread::park();
}
#[inline]
pub(crate) fn park_thread_timeout(duration: Duration) {
thread::park_timeout(duration);
}
#[inline]
pub(crate) fn unpark_thread(thread: &thread::Thread) {
thread.unpark();
}
pub fn park_thread_timeout_cond<F>(timeout: Option<Duration>, stop_condition: F)
where
F: Fn() -> bool,
{
if stop_condition() {
return;
}
match timeout {
Some(t) => thread::park_timeout(t),
None => thread::park(),
}
}