[][src]Module kayrx::timer

Utilities for tracking time.

This crate provides a number of utilities for working with periods of time:

  • Delay: A future that completes at a specified instant in time.

  • Interval A stream that yields at fixed time intervals.

  • Throttle: Throttle down a stream by enforcing a fixed delay between items.

  • Timeout: Wraps a future or stream, setting an upper bound to the amount of time it is allowed to execute. If the future or stream does not complete in time, then it is canceled and an error is returned.

  • DelayQueue: A queue where items are returned once the requested delay has expired.

These three types are backed by a Timer instance. In order for Delay, Interval, and Timeout to function, the associated Timer instance must be running on some thread.

Modules

delay_queue

A queue of delayed elements.

Structs

Clock

A handle to a source of time.

Delay

A future that completes at a specified instant in time.

DelayQueue

A queue of delayed elements.

Elapsed

Error returned by Timeout.

Error

Errors encountered by the timer implementation.

Handle

Handle to timer instance.

Interval

A stream representing notifications at fixed interval

SystemNow

A handle to a source of time.

Throttle

Slow down a stream by enforcing a delay between items.

Timeout

Allows a Future or Stream to execute for a limited amount of time.

Timer

Timer implementation that drives Delay, Interval, and Timeout.

Turn

Return value from the turn method on Timer.

Traits

Now

Returns Instant values representing the current instant in time.

Functions

delay

Create a Future that completes at deadline.

delay_for

Create a Future that completes in duration from now.

now

Returns an Instant corresponding to "now".

set_default

Sets handle to default timer, returning guard that unsets it on drop.

with_default

Set the default clock for the duration of the closure.