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

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

#132 in Date and time

Download history 24236/week @ 2024-11-15 25329/week @ 2024-11-22 21676/week @ 2024-11-29 21960/week @ 2024-12-06 21883/week @ 2024-12-13 12932/week @ 2024-12-20 8826/week @ 2024-12-27 18582/week @ 2025-01-03 22001/week @ 2025-01-10 21467/week @ 2025-01-17 23407/week @ 2025-01-24 23510/week @ 2025-01-31 23174/week @ 2025-02-07 22275/week @ 2025-02-14 26279/week @ 2025-02-21 17805/week @ 2025-02-28

94,232 downloads per month
Used in 229 crates (40 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