[][src]Struct futures_intrusive::timer::GenericTimerService

pub struct GenericTimerService<MutexType: RawMutex> { /* fields omitted */ }

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.

Methods

impl<MutexType: RawMutex> GenericTimerService<MutexType>[src]

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

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.

pub fn next_expiration(&self) -> Option<u64>[src]

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.

pub fn check_expirations(&self)[src]

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

Trait Implementations

impl<MutexType: RawMutex> Debug for GenericTimerService<MutexType>[src]

impl<MutexType: RawMutex> LocalTimer for GenericTimerService<MutexType>[src]

fn delay(&self, delay: Duration) -> LocalTimerFuture[src]

Returns a future that gets fulfilled after the given Duration

fn deadline(&self, timestamp: u64) -> LocalTimerFuture[src]

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

impl<MutexType: RawMutex + Send> Send for GenericTimerService<MutexType>[src]

impl<MutexType: RawMutex + Sync> Sync for GenericTimerService<MutexType>[src]

impl<MutexType: RawMutex> Timer for GenericTimerService<MutexType> where
    MutexType: Sync
[src]

fn delay(&self, delay: Duration) -> TimerFuture[src]

Returns a future that gets fulfilled after the given Duration

fn deadline(&self, timestamp: u64) -> TimerFuture[src]

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

Auto Trait Implementations

impl<MutexType> !RefUnwindSafe for GenericTimerService<MutexType>

impl<MutexType> Unpin for GenericTimerService<MutexType> where
    MutexType: Unpin

impl<MutexType> !UnwindSafe for GenericTimerService<MutexType>

Blanket Implementations

impl<T> Any for T where
    T: 'static + ?Sized
[src]

impl<T> Borrow<T> for T where
    T: ?Sized
[src]

impl<T> BorrowMut<T> for T where
    T: ?Sized
[src]

impl<T> From<T> for T[src]

impl<T, U> Into<U> for T where
    U: From<T>, 
[src]

impl<T, U> TryFrom<U> for T where
    U: Into<T>, 
[src]

type Error = Infallible

The type returned in the event of a conversion error.

impl<T, U> TryInto<U> for T where
    U: TryFrom<T>, 
[src]

type Error = <U as TryFrom<T>>::Error

The type returned in the event of a conversion error.