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.

As of calloop v0.11.0, the event loop always uses high-precision timers. However, the timer precision varies between operating systems; for instance, the scheduler granularity on Windows is about 16 milliseconds. 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.


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