#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

#1794 in Asynchronous

Download history 308/week @ 2024-01-05 187/week @ 2024-01-12 198/week @ 2024-01-19 278/week @ 2024-01-26 399/week @ 2024-02-02 340/week @ 2024-02-09 245/week @ 2024-02-16 193/week @ 2024-02-23 145/week @ 2024-03-01 152/week @ 2024-03-08 170/week @ 2024-03-15 341/week @ 2024-03-22 501/week @ 2024-03-29 359/week @ 2024-04-05 356/week @ 2024-04-12 238/week @ 2024-04-19

1,581 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