pub struct Timers<T> { /* private fields */ }
Available on crate feature
net
only.Expand description
A TimerMap
with an async method to wait for the next timer expiration.
Implementations§
Source§impl<T> Timers<T>
impl<T> Timers<T>
Sourcepub fn insert(&mut self, instant: Instant, item: T)
pub fn insert(&mut self, instant: Instant, item: T)
Insert a new entry at the specified instant
Sourcepub async fn wait_and_drain(&mut self) -> impl Iterator<Item = (Instant, T)>
pub async fn wait_and_drain(&mut self) -> impl Iterator<Item = (Instant, T)>
Wait for the next timer to expire and return an iterator of all expired timers
If the TimerMap is empty, this will return a future that is pending forever. After inserting a new entry, prior futures returned from this method will not become ready. They should be dropped after calling Self::insert, and a new future as returned from this method should be awaited instead.
Trait Implementations§
Auto Trait Implementations§
impl<T> Freeze for Timers<T>
impl<T> !RefUnwindSafe for Timers<T>
impl<T> Send for Timers<T>where
T: Send,
impl<T> Sync for Timers<T>where
T: Sync,
impl<T> Unpin for Timers<T>
impl<T> !UnwindSafe for Timers<T>
Blanket Implementations§
§impl<'a, T, E> AsTaggedExplicit<'a, E> for Twhere
T: 'a,
impl<'a, T, E> AsTaggedExplicit<'a, E> for Twhere
T: 'a,
§impl<'a, T, E> AsTaggedImplicit<'a, E> for Twhere
T: 'a,
impl<'a, T, E> AsTaggedImplicit<'a, E> for Twhere
T: 'a,
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