[][src]Module tokio_timer::timer

Timer implementation.

This module contains the types needed to run a timer.

The Timer type runs the timer logic. It holds all the necessary state to track all associated Delay instances and delivering notifications once the deadlines are reached.

The Handle type is a reference to a Timer instance. This type is Clone, Send, and Sync. This type is used to create instances of Delay.

The Now trait describes how to get an Instant representing the current moment in time. SystemNow is the default implementation, where Now::now is implemented by calling Instant::now.

Timer is generic over Now. This allows the source of time to be customized. This ability is especially useful in tests and any environment where determinism is necessary.

Note, when using the Tokio runtime, the Timer does not need to be manually setup as the runtime comes pre-configured with a Timer instance.

Structs

DefaultGuard

A guard that resets the current timer to None when dropped.

Handle

Handle to timer instance.

SystemNow

A handle to a source of time.

Timer

Timer implementation that drives Delay, Interval, and Timeout.

Turn

Return value from the turn method on Timer.

Functions

set_default

Sets handle as the default timer, returning a guard that unsets it on drop.

with_default

Set the default timer for the duration of the closure.