#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

#161 in Date and time

Download history 17990/week @ 2024-07-20 17333/week @ 2024-07-27 19020/week @ 2024-08-03 19278/week @ 2024-08-10 21036/week @ 2024-08-17 20496/week @ 2024-08-24 20176/week @ 2024-08-31 24213/week @ 2024-09-07 18690/week @ 2024-09-14 19792/week @ 2024-09-21 18316/week @ 2024-09-28 20969/week @ 2024-10-05 22688/week @ 2024-10-12 22683/week @ 2024-10-19 20547/week @ 2024-10-26 19931/week @ 2024-11-02

89,834 downloads per month
Used in 217 crates (37 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