#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

#2108 in Asynchronous

Download history 95/week @ 2024-11-16 157/week @ 2024-11-23 123/week @ 2024-11-30 68/week @ 2024-12-07 184/week @ 2024-12-14 37/week @ 2024-12-21 33/week @ 2024-12-28 113/week @ 2025-01-04 269/week @ 2025-01-11 145/week @ 2025-01-18 230/week @ 2025-01-25 140/week @ 2025-02-01 279/week @ 2025-02-08 130/week @ 2025-02-15 93/week @ 2025-02-22 184/week @ 2025-03-01

715 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