#snooze

build snooze-rs

An experimental library for sleeping periodically

3 releases

Uses old Rust 2015

0.0.3 May 21, 2015
0.0.2 Apr 20, 2015
0.0.1 Apr 5, 2015

#37 in #sleeping

Download history 1/week @ 2023-11-04 3/week @ 2023-11-11 6/week @ 2023-11-18 10/week @ 2023-11-25 7/week @ 2023-12-02 2/week @ 2023-12-09 3/week @ 2023-12-16 7/week @ 2023-12-23 2/week @ 2023-12-30 1/week @ 2024-01-06 1/week @ 2024-01-13 9/week @ 2024-01-20 7/week @ 2024-01-27 1/week @ 2024-02-03 10/week @ 2024-02-10 58/week @ 2024-02-17

76 downloads per month

Apache-2.0

13KB
327 lines

snooze-rs

Experimental library for sleeping periodically in Rust code.

Build Status

Usage:

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.

Dependencies

~0.6–1MB
~14K SLoC