| Crates.io | snooze-rs |
| lib.rs | snooze-rs |
| version | 0.0.3 |
| created_at | 2015-04-05 09:12:09.658906+00 |
| updated_at | 2015-12-11 23:56:18.321051+00 |
| description | An experimental library for sleeping periodically |
| homepage | https://github.com/gekkio/snooze-rs |
| repository | https://github.com/gekkio/snooze-rs |
| max_upload_size | |
| id | 1777 |
| size | 12,743 |
Experimental library for sleeping periodically in Rust code.
Cargo.toml:
[dependencies]
snooze-rs = "0.0.3"
Crate root:
extern crate snooze;
extern crate time;
Basic usage:
use snooze::{Snooze, SnoozeError};
use time::duration::Duration;
fn sleep_and_work() -> Result<(), SnoozeError> {
let mut snooze = try!(Snooze::new(Duration::milliseconds(42)));
while should_continue() {
try!(snooze.wait());
do_things();
}
Ok(())
}
The function do_things() will be called approximately every 42 ms, depending on
system timer accuracy and assuming do_things() takes less than 42 ms.