pub struct Timer { /* private fields */ }Expand description
A simple async timer that can schedule waits and manage many concurrent timers.
The timer maintains an internal queue of expirations and a dedicated thread
that sleeps until the next expiration or is woken when a shorter timeout is
scheduled. Each call to Timer::wait returns a TimerFuture that
becomes ready when the configured duration elapses.
Implementations§
Source§impl Timer
impl Timer
Sourcepub fn wait(&mut self, duration: Duration) -> TimerFuture ⓘ
pub fn wait(&mut self, duration: Duration) -> TimerFuture ⓘ
Schedules a new timeout and returns a future that resolves when it expires.
Multiple waits can be outstanding at the same time; the timer keeps them ordered by expiration and wakes the appropriate futures when their deadlines are reached.
Trait Implementations§
Auto Trait Implementations§
impl Freeze for Timer
impl RefUnwindSafe for Timer
impl Send 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