#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

#139 in Date and time

Download history 19578/week @ 2024-09-20 18774/week @ 2024-09-27 20009/week @ 2024-10-04 22719/week @ 2024-10-11 22509/week @ 2024-10-18 21607/week @ 2024-10-25 18744/week @ 2024-11-01 21837/week @ 2024-11-08 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 14613/week @ 2025-01-03

62,537 downloads per month
Used in 226 crates (38 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