futures_intrusive::timer

Type Alias TimerService

source
pub type TimerService = GenericTimerService<RawMutex>;
Expand description

A GenericTimerService implementation backed by parking_lot.

Aliased Type§

struct TimerService { /* private fields */ }

Implementations

source§

impl<MutexType: RawMutex> GenericTimerService<MutexType>

source

pub fn new(clock: &'static dyn Clock) -> GenericTimerService<MutexType>

Creates a new Timer in the given state.

The Timer will query the provided Clock instance for the current time whenever required.

In order to create a create a clock which utilizes system time, StdClock can be utilized. In order to simulate time for test purposes, MockClock can be utilized.

source

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.

source

pub fn check_expirations(&self)

Checks whether any of the attached TimerFutures has expired. In this case the associated task is woken up.

Trait Implementations

source§

impl<MutexType: RawMutex> Debug for GenericTimerService<MutexType>

source§

fn fmt(&self, f: &mut Formatter<'_>) -> Result

Formats the value using the given formatter. Read more
source§

impl<MutexType: RawMutex> LocalTimer for GenericTimerService<MutexType>

source§

fn delay(&self, delay: Duration) -> LocalTimerFuture<'_>

Returns a future that gets fulfilled after the given Duration

source§

fn deadline(&self, timestamp: u64) -> LocalTimerFuture<'_>

Returns a future that gets fulfilled when the utilized Clock reaches the given timestamp.

source§

impl<MutexType> Timer for GenericTimerService<MutexType>
where MutexType: Sync + RawMutex,

source§

fn delay(&self, delay: Duration) -> TimerFuture<'_>

Returns a future that gets fulfilled after the given Duration

source§

fn deadline(&self, timestamp: u64) -> TimerFuture<'_>

Returns a future that gets fulfilled when the utilized Clock reaches the given timestamp.

source§

impl<MutexType: RawMutex + Send> Send for GenericTimerService<MutexType>

source§

impl<MutexType: RawMutex + Sync> Sync for GenericTimerService<MutexType>