schedule_recv

Crates.ioschedule_recv
lib.rsschedule_recv
version0.1.0
sourcesrc
created_at2015-05-01 21:50:49.661905
updated_at2016-05-14 15:47:55.148225
descriptionCreate delayed and periodic Receivers
homepagehttps://github.com/PeterReid/schedule_recv
repositoryhttps://github.com/PeterReid/schedule_recv
max_upload_size
id1999
size12,211
Peter Reid (PeterReid)

documentation

https://PeterReid.github.io/schedule_recv

README

This module exposes functionality to create receivers that receive notifications after a specified period of time or at a specified frequency.

Build status

Documentation

Examples

At its simplest, oneshot_ms can be used to put the thread to sleep. Unlike with std::thread::sleep, this could be used with Select to be waiting for one of several Receivers to fire.

use timer::oneshot_ms;

let timer = oneshot_ms(1500);
timer.recv().unwrap();
println!("1.5 seconds have elapsed.");

Periodic Receivers can be created using periodic_ms.

use timer::periodic_ms;

let tick = periodic_ms(2000);
thread::sleep_ms(1000);
let tock = periodic_ms(2000);
loop {
    tick.recv().unwrap();
    println!("Tick");
    tock.recv().unwrap();
    println!("Tock");
}
Commit count: 40

cargo fmt