#mio #timer #linux #timerfd

mio-timerfd

mio support for linux's timerfd

4 releases

0.2.0 May 2, 2020
0.1.2 Oct 5, 2019
0.1.1 Sep 23, 2019
0.1.0 Sep 17, 2019

#1715 in Asynchronous

Download history 161/week @ 2023-12-10 332/week @ 2023-12-17 203/week @ 2023-12-24 293/week @ 2023-12-31 293/week @ 2024-01-07 144/week @ 2024-01-14 196/week @ 2024-01-21 333/week @ 2024-01-28 432/week @ 2024-02-04 275/week @ 2024-02-11 284/week @ 2024-02-18 125/week @ 2024-02-25 200/week @ 2024-03-03 96/week @ 2024-03-10 189/week @ 2024-03-17 392/week @ 2024-03-24

881 downloads per month
Used in pulseaudio

MIT license

22KB
366 lines

mio-timerfd

crates.io license build status

A mio wrapper for linux's timerfd feature. For linux-specific software this is likely the easiest (and probably most performant, but I'm not benchmarking) way to get asynchronous timers into your code.

simple example

let poll = Poll::new().unwrap();
let mut events = Events::with_capacity(1024);
let mut timer = TimerFd::new(ClockId::Monotonic).unwrap();
timer.set_timeout_interval(&Duration::from_millis(10)).unwrap();
poll.register(&timer, Token(0), Ready::readable(), PollOpt::edge())
	.unwrap();

// effectively sleeps the thread for 10ms
poll.poll(&mut events, None).unwrap();
assert!(timer.read().unwrap() == 1);

Dependencies

~0.5–0.8MB
~14K SLoC