Skip to main content

tokio_os_timer/
lib.rs

1//! This crate provides timers for use with tokio that rely on OS mechanisms for timer management
2//! rather than a separate timing mechanism like [`tokio-timer`]. This comes at somewhat increased
3//! overhead if you have many timers, but allows the timers to have any granularity supported by
4//! your operating system where `tokio-timer` can only support timers with a granularity of 1ms.
5//! In particular, the system timers usually support whatever granularity the underlying hardware
6//! supports (see "High-resolution timers" in [`time(7)`]), which on my laptop is 1ns!
7//! Realistically, you won't be able to make your timers higher resolution than how long system
8//! calls on your system take, which is usually on the order of hundreds of nanoseconds.
9//!
10//! The current implementation uses [`timerfd_create(2)`] on Linux, and [`kqueue(2)` timers] on
11//! macOS and BSDs.
12//!
13//!   [`tokio-timer`]: https://docs.rs/tokio-timer/
14//!   [`timerfd_create(2)`]: https://linux.die.net/man/2/timerfd_settime
15//!   [`kqueue(2)` timers]: https://man.openbsd.org/kqueue.2
16//!   [`time(7)`]: https://linux.die.net/man/7/time
17
18#![deny(missing_docs)]
19
20mod delay;
21pub use self::delay::Delay;
22
23mod interval;
24pub use self::interval::Interval;
25
26mod sys;