[−][src]Struct vmm_sys_util::timerfd::TimerFd
A safe wrapper around a Linux
timerfd
.
Implementations
impl TimerFd
[src]
pub fn new() -> Result<TimerFd>
[src]
Create a new TimerFd
.
This creates a nonsettable monotonically increasing clock that does not
change after system startup. The timer is initally disarmed and must be
armed by calling reset
.
pub fn reset(&mut self, dur: Duration, interval: Option<Duration>) -> Result<()>
[src]
Arm the TimerFd
.
Set the timer to expire after dur
.
Arguments
dur
: Specify the initial expiration of the timer.interval
: Specify the period for repeated expirations, depending on the value passed. Ifinterval
is notNone
, it represents the period after the initial expiration. Otherwise the timer will expire just once. Cancels any existing duration and repeating interval.
Examples
extern crate vmm_sys_util; use vmm_sys_util::timerfd::TimerFd; let mut timer = TimerFd::new().unwrap(); let dur = Duration::from_millis(100); let interval = Duration::from_millis(100); timer.reset(dur, Some(interval)).unwrap();
pub fn wait(&mut self) -> Result<u64>
[src]
Wait until the timer expires.
The return value represents the number of times the timer has expired since
the last time wait
was called. If the timer has not yet expired once,
this call will block until it does.
Examples
extern crate vmm_sys_util; use vmm_sys_util::timerfd::TimerFd; let mut timer = TimerFd::new().unwrap(); let dur = Duration::from_millis(100); let interval = Duration::from_millis(100); timer.reset(dur, Some(interval)).unwrap(); sleep(dur * 3); let count = timer.wait().unwrap(); assert!(count >= 3);
pub fn is_armed(&self) -> Result<bool>
[src]
Tell if the timer is armed.
Returns Ok(true)
if the timer is currently armed, otherwise the errno set by
timerfd_gettime
.
Examples
extern crate vmm_sys_util; use vmm_sys_util::timerfd::TimerFd; let mut timer = TimerFd::new().unwrap(); let dur = Duration::from_millis(100); timer.reset(dur, None).unwrap(); assert!(timer.is_armed().unwrap());
pub fn clear(&mut self) -> Result<()>
[src]
Disarm the timer.
Set zero to disarm the timer, referring to
timerfd_settime
.
Examples
extern crate vmm_sys_util; use vmm_sys_util::timerfd::TimerFd; let mut timer = TimerFd::new().unwrap(); let dur = Duration::from_millis(100); timer.reset(dur, None).unwrap(); timer.clear().unwrap();
Trait Implementations
impl AsRawFd for TimerFd
[src]
impl FromRawFd for TimerFd
[src]
unsafe fn from_raw_fd(fd: RawFd) -> Self
[src]
impl IntoRawFd for TimerFd
[src]
fn into_raw_fd(self) -> RawFd
[src]
Auto Trait Implementations
impl RefUnwindSafe for TimerFd
impl Send for TimerFd
impl Sync for TimerFd
impl Unpin for TimerFd
impl UnwindSafe for TimerFd
Blanket Implementations
impl<T> Any for T where
T: 'static + ?Sized,
[src]
T: 'static + ?Sized,
impl<T> Borrow<T> for T where
T: ?Sized,
[src]
T: ?Sized,
impl<T> BorrowMut<T> for T where
T: ?Sized,
[src]
T: ?Sized,
pub fn borrow_mut(&mut self) -> &mut T
[src]
impl<T> From<T> for T
[src]
impl<T, U> Into<U> for T where
U: From<T>,
[src]
U: From<T>,
impl<T, U> TryFrom<U> for T where
U: Into<T>,
[src]
U: Into<T>,
type Error = Infallible
The type returned in the event of a conversion error.
pub fn try_from(value: U) -> Result<T, <T as TryFrom<U>>::Error>
[src]
impl<T, U> TryInto<U> for T where
U: TryFrom<T>,
[src]
U: TryFrom<T>,