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

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.

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.

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

Trait Implementations

Formats the value using the given formatter. Read more

Returns a future that gets fulfilled after the given Duration

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

Returns a future that gets fulfilled after the given Duration

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

Auto Trait Implementations

Blanket Implementations

Gets the TypeId of self. Read more
Immutably borrows from an owned value. Read more
Mutably borrows from an owned value. Read more

Returns the argument unchanged.

Calls U::from(self).

That is, this conversion is whatever the implementation of From<T> for U chooses to do.

The type returned in the event of a conversion error.
Performs the conversion.
The type returned in the event of a conversion error.
Performs the conversion.