Struct openrr_sleep::ScopedSleep [−][src]
pub struct ScopedSleep { /* fields omitted */ }
Expand description
RAII sleep
Implementations
Create sleep
Example
let now = std::time::Instant::now(); { // Do not use `let _ = ..` here because it immediately drops ScopedSleep. let _guard = openrr_sleep::ScopedSleep::new(std::time::Duration::from_millis(100)); // not sleep yet assert!(now.elapsed() < std::time::Duration::from_millis(20)); } // sleeped assert!(now.elapsed() > std::time::Duration::from_millis(20));
Create sleep from float secs value
Example
let now = std::time::Instant::now(); { // Do not use `let _ = ..` here because it immediately drops ScopedSleep. let _guard = openrr_sleep::ScopedSleep::from_secs(0.1); // not sleep yet assert!(now.elapsed() < std::time::Duration::from_millis(10)); } // sleeped assert!(now.elapsed() > std::time::Duration::from_millis(10));
Trait Implementations
Auto Trait Implementations
impl RefUnwindSafe for ScopedSleep
impl Send for ScopedSleep
impl Sync for ScopedSleep
impl Unpin for ScopedSleep
impl UnwindSafe for ScopedSleep