Struct futures_intrusive::timer::GenericTimerService
source · pub struct GenericTimerService<MutexType: RawMutex> { /* private fields */ }
Expand description
An asynchronously awaitable timer.
The timer operates on millisecond precision and makes use of a configurable clock source.
The timer allows to wait asynchronously either for a certain duration,
or until the provided Clock
reaches a certain timestamp.
In order to unblock tasks that are waiting on the timer,
check_expirations
must be called in regular intervals on this timer service.
The timer can either be running on a separate timer thread (in case a thread-safe timer type is utilize), or it can be integrated into an executor in order to minimize context switches.
Implementations
sourceimpl<MutexType: RawMutex> GenericTimerService<MutexType>
impl<MutexType: RawMutex> GenericTimerService<MutexType>
sourcepub fn new(clock: &'static dyn Clock) -> GenericTimerService<MutexType>
pub fn new(clock: &'static dyn Clock) -> GenericTimerService<MutexType>
sourcepub fn next_expiration(&self) -> Option<u64>
pub fn next_expiration(&self) -> Option<u64>
Returns a timestamp when the next timer expires.
For thread-safe timers, the returned value is not precise and subject to race-conditions, since other threads can add timer in the meantime.
Therefore adding any timer to the GenericTimerService
should also
make sure to wake up the executor which polls for timeouts, in order to
let it capture the latest change.
sourcepub fn check_expirations(&self)
pub fn check_expirations(&self)
Checks whether any of the attached TimerFuture
s has expired.
In this case the associated task is woken up.
Trait Implementations
sourceimpl<MutexType: RawMutex> Debug for GenericTimerService<MutexType>
impl<MutexType: RawMutex> Debug for GenericTimerService<MutexType>
sourceimpl<MutexType: RawMutex> LocalTimer for GenericTimerService<MutexType>
impl<MutexType: RawMutex> LocalTimer for GenericTimerService<MutexType>
sourcefn delay(&self, delay: Duration) -> LocalTimerFuture<'_>ⓘNotable traits for LocalTimerFuture<'a>impl<'a> Future for LocalTimerFuture<'a> type Output = ();
fn delay(&self, delay: Duration) -> LocalTimerFuture<'_>ⓘNotable traits for LocalTimerFuture<'a>impl<'a> Future for LocalTimerFuture<'a> type Output = ();
Returns a future that gets fulfilled after the given Duration
sourcefn deadline(&self, timestamp: u64) -> LocalTimerFuture<'_>ⓘNotable traits for LocalTimerFuture<'a>impl<'a> Future for LocalTimerFuture<'a> type Output = ();
fn deadline(&self, timestamp: u64) -> LocalTimerFuture<'_>ⓘNotable traits for LocalTimerFuture<'a>impl<'a> Future for LocalTimerFuture<'a> type Output = ();
Returns a future that gets fulfilled when the utilized Clock
reaches
the given timestamp.
sourceimpl<MutexType: RawMutex> Timer for GenericTimerService<MutexType>where
MutexType: Sync,
impl<MutexType: RawMutex> Timer for GenericTimerService<MutexType>where
MutexType: Sync,
sourcefn delay(&self, delay: Duration) -> TimerFuture<'_>ⓘNotable traits for TimerFuture<'a>impl<'a> Future for TimerFuture<'a> type Output = ();
fn delay(&self, delay: Duration) -> TimerFuture<'_>ⓘNotable traits for TimerFuture<'a>impl<'a> Future for TimerFuture<'a> type Output = ();
Returns a future that gets fulfilled after the given Duration
sourcefn deadline(&self, timestamp: u64) -> TimerFuture<'_>ⓘNotable traits for TimerFuture<'a>impl<'a> Future for TimerFuture<'a> type Output = ();
fn deadline(&self, timestamp: u64) -> TimerFuture<'_>ⓘNotable traits for TimerFuture<'a>impl<'a> Future for TimerFuture<'a> type Output = ();
Returns a future that gets fulfilled when the utilized Clock
reaches
the given timestamp.