isleep
Provides the functions snooze and accurate_snooze for intermittent sleeping which return the control flow inbetween.
Relies on platform support for std::time and std::thread.
Example
// Sleeping for a total of 1 s
let total = from_secs;
// Interrupting the sleep after 100 ms
let len = from_millis;
// Starting now
let start = now;
// Sleeps for `total` in steps up to `len`
// Wont sleep longer than `total` within accuracy of the platform
while snooze
Accuracy
The accuracy is platform dependent and might be low for small durations (eg: <20 ms on Windows).
Higher accuracy can be achieved with the accuracy feature and accurate_snooze which
utilizes spin_sleep.
cargo add isleep --features=accuracy