Module calloop::timer

source ·
Expand description

Timer event source

The Timer is an event source that will fire its event after a certain amount of time specified at creation. Its timing is tracked directly by the event loop core logic, and it does not consume any system resource.

The timer precision depends on whether the loop was initialized in high-precision mode. If not, you can expect precision of order of 1 millisecond, if you need sub-millisecond precision, make sure you initialize the EventLoop using EventLoop::try_new_high_precision(). Note also that if you need to rely on good precision timers in general, you may need to enable realtime features of your OS to ensure your thread is quickly woken up by the system scheduler.

The provided event is an Instant representing the deadline for which this timer has fired (which can be earlier than the current time depending on the event loop congestion).

The callback associated with this event source is expected to return a TimeoutAction, which can be used to implement self-repeating timers by telling calloop to reprogram the same timer for a later timeout after it has fired.

Structs

  • A future that resolves once a certain timeout is expired
  • A timer event source

Enums