Struct TimerFd

Source
pub struct TimerFd { /* private fields */ }
Expand description

A timerfd which can be used to create mio-compatible timers on linux targets.

Implementations§

Source§

impl TimerFd

Source

pub fn new(clockid: ClockId) -> Result<Self>

Create a new timerfd using the given clock; if you’re not sure what clock to use read timerfd(7) for more details, or know that ClockId::Monotonic is a good default for most programs.

Source

pub fn set_timeout(&mut self, timeout: &Duration) -> Result<()>

Set a single timeout to occur after the specified duration.

Source

pub fn set_timeout_interval(&mut self, timeout: &Duration) -> Result<()>

Set a timeout to occur at each interval of the specified duration from this point in time forward.

Source

pub fn disarm(&mut self) -> Result<()>

Unset any existing timeouts on the timer, making this timerfd inert until rearmed.

Source

pub fn read(&self) -> Result<u64>

Read the timerfd to reset the readability of the timerfd, and allow determining how many times the timer has elapsed since the last read. This should usually be read after any wakeups caused by this timerfd, as reading the timerfd is important to reset the readability of the timerfd.

Failing to call this after this timerfd causes a wakeup will result in immediately re-waking on this timerfd if level polling, or never re-waking if edge polling.

Source

pub fn create(clockid: c_int, flags: c_int) -> Result<Self>

Wrapper of timerfd_create from timerfd_create(7); For most users it’s probably easier to use the TimerFd::new.

Note that this library may cause the thread to block when TimerFd::read is called if the TFD_NONBLOCK flag is not included in the flags.

Source

pub fn settime( &mut self, flags: c_int, new_value: &itimerspec, ) -> Result<itimerspec>

Wrapper of timerfd_settime from timerfd_create(7); For most users it’s probably easier to use the TimerFd::set_timeout or the TimerFd::set_timeout_interval functions.

Source

pub fn gettime(&self) -> Result<itimerspec>

Wrapper of timerfd_gettime from timerfd_create(7)

Trait Implementations§

Source§

impl AsRawFd for TimerFd

Source§

fn as_raw_fd(&self) -> RawFd

Extracts the raw file descriptor. Read more
Source§

impl Drop for TimerFd

Source§

fn drop(&mut self)

Executes the destructor for this type. Read more
Source§

impl Source for TimerFd

Source§

fn register( &mut self, registry: &Registry, token: Token, interest: Interest, ) -> Result<()>

Register self with the given Registry instance. Read more
Source§

fn reregister( &mut self, registry: &Registry, token: Token, interest: Interest, ) -> Result<()>

Re-register self with the given Registry instance. Read more
Source§

fn deregister(&mut self, registry: &Registry) -> Result<()>

Deregister self from the given Registry instance. Read more

Auto Trait Implementations§

Blanket Implementations§

Source§

impl<T> Any for T
where T: 'static + ?Sized,

Source§

fn type_id(&self) -> TypeId

Gets the TypeId of self. Read more
Source§

impl<T> Borrow<T> for T
where T: ?Sized,

Source§

fn borrow(&self) -> &T

Immutably borrows from an owned value. Read more
Source§

impl<T> BorrowMut<T> for T
where T: ?Sized,

Source§

fn borrow_mut(&mut self) -> &mut T

Mutably borrows from an owned value. Read more
Source§

impl<T> From<T> for T

Source§

fn from(t: T) -> T

Returns the argument unchanged.

Source§

impl<T, U> Into<U> for T
where U: From<T>,

Source§

fn into(self) -> U

Calls U::from(self).

That is, this conversion is whatever the implementation of From<T> for U chooses to do.

Source§

impl<T, U> TryFrom<U> for T
where U: Into<T>,

Source§

type Error = Infallible

The type returned in the event of a conversion error.
Source§

fn try_from(value: U) -> Result<T, <T as TryFrom<U>>::Error>

Performs the conversion.
Source§

impl<T, U> TryInto<U> for T
where U: TryFrom<T>,

Source§

type Error = <U as TryFrom<T>>::Error

The type returned in the event of a conversion error.
Source§

fn try_into(self) -> Result<U, <U as TryFrom<T>>::Error>

Performs the conversion.