Module nix::sys::timerfd [−][src]
Timer API via file descriptors.
Timer FD is a Linux-only API to create timers and get expiration notifications through file descriptors.
For more documentation, please read timerfd_create(2).
Examples
Create a new one-shot timer that expires after 1 second.
// We create a new monotonic timer. let timer = TimerFd::new(ClockId::CLOCK_MONOTONIC, TimerFlags::empty()) .unwrap(); // We set a new one-shot timer in 1 seconds. timer.set( Expiration::OneShot(TimeSpec::seconds(1)), TimerSetTimeFlags::empty() ).unwrap(); // We wait for the timer to expire. timer.wait().unwrap();
Structs
TimerFd | A timerfd instance. This is also a file descriptor, you can feed it to other interfaces consuming file descriptors, epoll for example. |
TimerFlags | Additional flags to change the behaviour of the file descriptor at the time of creation. |
TimerSetTimeFlags | Flags that are used for arming the timer. |
Enums
ClockId | The type of the clock used to mark the progress of the timer. For more details on each kind of clock, please refer to timerfd_create(2). |
Expiration | An enumeration allowing the definition of the expiration time of an alarm, recurring or not. |