#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

#153 in Date and time

Download history 22755/week @ 2024-10-21 20412/week @ 2024-10-28 20285/week @ 2024-11-04 21827/week @ 2024-11-11 25356/week @ 2024-11-18 22836/week @ 2024-11-25 22681/week @ 2024-12-02 21688/week @ 2024-12-09 22227/week @ 2024-12-16 9665/week @ 2024-12-23 10402/week @ 2024-12-30 20135/week @ 2025-01-06 22505/week @ 2025-01-13 21945/week @ 2025-01-20 23127/week @ 2025-01-27 21770/week @ 2025-02-03

90,329 downloads per month
Used in 228 crates (39 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