pub struct Timer { /* private fields */ }
Expand description
A Timer generating event after a given time
Use MiocoHandle::select()
to wait for an event, or read()
to block until
done.
Note the timer effective resolution is limited by underlying mio timer.
See mioco::sleep()
for details.
Implementations§
Source§impl Timer
impl Timer
Sourcepub fn read(&mut self) -> Instant
pub fn read(&mut self) -> Instant
Read a timer to block on it until it is done.
Returns current time
TODO: Return wakeup time instead
Sourcepub fn try_read(&mut self) -> Option<Instant>
pub fn try_read(&mut self) -> Option<Instant>
Try reading current time (if the timer is done)
TODO: Return wakeup time instead
Sourcepub fn set_timeout(&mut self, delay_ms: u64)
pub fn set_timeout(&mut self, delay_ms: u64)
Set timeout for the timer
The timeout counts from the time set_timeout
is called.
Note the timer effective resolution is limited by underlying mio
timer. See mioco::sleep()
for details.
Sourcepub fn set_timeout_absolute(&mut self, timeout: Instant)
pub fn set_timeout_absolute(&mut self, timeout: Instant)
Set timeout for the timer using absolute time.
Sourcepub fn get_timeout_absolute(&mut self) -> Instant
pub fn get_timeout_absolute(&mut self) -> Instant
Get absolute value of the timer timeout.
Trait Implementations§
Auto Trait Implementations§
impl Freeze for Timer
impl !RefUnwindSafe for Timer
impl !Sync for Timer
impl Unpin for Timer
impl !UnwindSafe for Timer
Blanket Implementations§
Source§impl<T> BorrowMut<T> for Twhere
T: ?Sized,
impl<T> BorrowMut<T> for Twhere
T: ?Sized,
Source§fn borrow_mut(&mut self) -> &mut T
fn borrow_mut(&mut self) -> &mut T
Mutably borrows from an owned value. Read more