#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

#1853 in Asynchronous

Download history 145/week @ 2024-03-14 261/week @ 2024-03-21 509/week @ 2024-03-28 419/week @ 2024-04-04 354/week @ 2024-04-11 312/week @ 2024-04-18 294/week @ 2024-04-25 163/week @ 2024-05-02 273/week @ 2024-05-09 220/week @ 2024-05-16 254/week @ 2024-05-23 534/week @ 2024-05-30 456/week @ 2024-06-06 280/week @ 2024-06-13 271/week @ 2024-06-20 217/week @ 2024-06-27

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