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§
Source§impl<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 the expiration and value of all scheduled timers
Sourcepub fn iter_mut(&mut self) -> impl ExactSizeIterator<Item = (u64, &mut T)>
pub fn iter_mut(&mut self) -> impl ExactSizeIterator<Item = (u64, &mut T)>
Iterate over the expiration and value of all scheduled timers
Trait Implementations§
Source§impl<T: Clone> Clone for TimerQueue<T>
impl<T: Clone> Clone for TimerQueue<T>
Source§fn clone(&self) -> TimerQueue<T>
fn clone(&self) -> TimerQueue<T>
1.0.0 · Source§fn clone_from(&mut self, source: &Self)
fn clone_from(&mut self, source: &Self)
source
. Read more