Struct timer_queue::TimerQueue
source · [−]pub struct TimerQueue<T> { /* private fields */ }
Expand description
Stores values to be yielded at specific times in the future
Time is expressed as a bare u64 representing an absolute point in time. The caller may use any
consistent unit, e.g. milliseconds, and any consistent definition of time zero. Larger units
limit resolution but make poll
ing over the same real-time interval proportionately faster,
whereas smaller units improve resolution, limit total range, and reduce poll
performance.
Implementations
sourceimpl<T> TimerQueue<T>
impl<T> TimerQueue<T>
sourcepub fn with_capacity(n: usize) -> Self
pub fn with_capacity(n: usize) -> Self
Create a queue for which at least n
calls to insert
will not require a reallocation
sourcepub fn poll(&mut self, now: u64) -> Option<T>
pub fn poll(&mut self, now: u64) -> Option<T>
Returns a timer that has expired by now
, if any
now
must be at least the largest previously passed value
sourcepub fn next_timeout(&self) -> Option<u64>
pub fn next_timeout(&self) -> Option<u64>
Lower bound on when the next timer will expire, if any
sourcepub fn insert(&mut self, timeout: u64, value: T) -> Timer
pub fn insert(&mut self, timeout: u64, value: T) -> Timer
Register a timer that will yield value
at timeout
sourcepub fn iter(&self) -> impl ExactSizeIterator<Item = (u64, &T)>
pub fn iter(&self) -> impl ExactSizeIterator<Item = (u64, &T)>
Iterate over all scheduled timers
Trait Implementations
sourceimpl<T: Clone> Clone for TimerQueue<T>
impl<T: Clone> Clone for TimerQueue<T>
sourcefn clone(&self) -> TimerQueue<T>
fn clone(&self) -> TimerQueue<T>
Returns a copy of the value. Read more
1.0.0 · sourcefn clone_from(&mut self, source: &Self)
fn clone_from(&mut self, source: &Self)
Performs copy-assignment from
source
. Read moresourceimpl<T: Debug> Debug for TimerQueue<T>
impl<T: Debug> Debug for TimerQueue<T>
Auto Trait Implementations
impl<T> RefUnwindSafe for TimerQueue<T>where
T: RefUnwindSafe,
impl<T> Send for TimerQueue<T>where
T: Send,
impl<T> Sync for TimerQueue<T>where
T: Sync,
impl<T> Unpin for TimerQueue<T>where
T: Unpin,
impl<T> UnwindSafe for TimerQueue<T>where
T: UnwindSafe,
Blanket Implementations
sourceimpl<T> BorrowMut<T> for Twhere
T: ?Sized,
impl<T> BorrowMut<T> for Twhere
T: ?Sized,
const: unstable · sourcefn borrow_mut(&mut self) -> &mut T
fn borrow_mut(&mut self) -> &mut T
Mutably borrows from an owned value. Read more