#mio #timerfd #timer #linux

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

#2556 in Asynchronous

Download history 78/week @ 2025-10-21 109/week @ 2025-10-28 101/week @ 2025-11-04 82/week @ 2025-11-11 136/week @ 2025-11-18 88/week @ 2025-11-25 84/week @ 2025-12-02 64/week @ 2025-12-09 29/week @ 2025-12-16 41/week @ 2025-12-23 41/week @ 2025-12-30 87/week @ 2026-01-06 88/week @ 2026-01-13 62/week @ 2026-01-20 106/week @ 2026-01-27 88/week @ 2026-02-03

365 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