pub struct TimerFd { /* private fields */ }
Expand description
A synchronious
timer instance based on the Linux’s timerfd_create
.
A EPoll
or select
can be used to monitor the instance. Also the
instance implements Future which can be polled from async code. Or
used with tokio’s AsyncFd
or any other equivalent.
Implementations§
Source§impl TimerFd
impl TimerFd
Sourcepub fn set_nonblocking(&self) -> TimerPortResult<()>
pub fn set_nonblocking(&self) -> TimerPortResult<()>
Sets the timer to nonblocking mode for read
operation. If the timer was inited with
TimerFlags::TFD_NONBLOCK, then this will not do anything.
Trait Implementations§
Source§impl AsFd for TimerFd
impl AsFd for TimerFd
Source§fn as_fd(&self) -> BorrowedFd<'_>
fn as_fd(&self) -> BorrowedFd<'_>
Source§impl AsTimerFd for TimerFd
impl AsTimerFd for TimerFd
Source§fn get_bind(&self) -> Option<Arc<DefaultEventWatch>>
fn get_bind(&self) -> Option<Arc<DefaultEventWatch>>
Source§fn bind_poll(&self, timer_weak_ref: Weak<DefaultEventWatch>)
fn bind_poll(&self, timer_weak_ref: Weak<DefaultEventWatch>)
Source§fn unbind_poll(&self)
fn unbind_poll(&self)
Source§impl FdTimerCom for TimerFd
impl FdTimerCom for TimerFd
Source§fn read(&self) -> TimerPortResult<TimerReadRes<u64>>
fn read(&self) -> TimerPortResult<TimerReadRes<u64>>
Reads the FD.
§Returns
-
If FD is configured as non-blocking then returns TimerReadRes::WouldBlock otherwise would block.
-
If daytime modification happened the TimerReadRes::Cancelled will be returned, however it depends if the [TimerSetTimeFlags::TFD_TIMER_CANCEL_ON_SET] is set with [TimerSetTimeFlags::TFD_TIMER_ABSTIME].
-
If read was successfull the amount of the overflows before read will be returned i.e TimerReadRes::Ok. Normally is is
1
. If0
is returned then probably the time or day was modified. -
The Result::Err is returned if other error occured.
Source§fn set_time<TIMERTYPE: ModeTimeType>(
&self,
timer_exp: TimerExpMode<TIMERTYPE>,
) -> TimerPortResult<()>
fn set_time<TIMERTYPE: ModeTimeType>( &self, timer_exp: TimerExpMode<TIMERTYPE>, ) -> TimerPortResult<()>
Sets the timer with the specific flags and time experation mode.
The timer_exp
time must be in future if [TimerSetTimeFlags::TFD_TIMER_ABSTIME] was
selected.
§Arguments
-
flags
- [TimerSetTimeFlags] flags. -
timer_exp
- TimerExpMode a timer mode.
§Returns
The Result::Err is returned if other error occured.