#chrono #schedule #alarm #chronometer #duration-seconds

timer

A simple timer. Use it to schedule execution of closures after a delay or at a given timestamp.

8 releases

Uses old Rust 2015

0.2.0 Sep 11, 2017
0.1.6 Mar 11, 2016

#5 in #alarm

Download history 20764/week @ 2024-06-16 18429/week @ 2024-06-23 14491/week @ 2024-06-30 17642/week @ 2024-07-07 18077/week @ 2024-07-14 17899/week @ 2024-07-21 17313/week @ 2024-07-28 19114/week @ 2024-08-04 19265/week @ 2024-08-11 21415/week @ 2024-08-18 20532/week @ 2024-08-25 19970/week @ 2024-09-01 24523/week @ 2024-09-08 18049/week @ 2024-09-15 19887/week @ 2024-09-22 17412/week @ 2024-09-29

81,183 downloads per month
Used in 214 crates (35 directly)

MPL-2.0 license

31KB
414 lines

Timer

Build Status

Simple implementation of a Timer in and for Rust.

Example

extern crate timer;
extern crate chrono;
use std::sync::mpsc::channel;

let timer = timer::Timer::new();
let (tx, rx) = channel();

timer.schedule_with_delay(chrono::Duration::seconds(3), move || {
  tx.send(()).unwrap();
});

rx.recv().unwrap();
println!("This code has been executed after 3 seconds");

lib.rs:

A simple timer, used to enqueue operations meant to be executed at a given time or after a given delay.

Dependencies

~1MB
~18K SLoC