package tezt

  1. Overview
  2. Docs

Call functions after a given amount of time.

Timers trigger in the scheduler process, and only if they were created in the scheduler process. If a worker runs a scheduler itself, this worker does not inherit the timers from its parent scheduler.

type t

Timers.

val on_delay : float -> (unit -> unit) -> t

Create a timer.

Usage: on_delay delay f

This causes run to trigger f () after delay seconds. This also causes run to not return until this timer has triggered, even if all tasks are done, unless the timer is canceled.

val cancel : t -> unit

Cancel a timer.

This removes the timer from the list of active timers. The function associated with the timer will not be triggered by run, and run will not wait for the timer to occur.

If the timer has already been triggered, this has no effect.

val cancel_all : unit -> unit

Cancel all active timers.

OCaml

Innovation. Community. Security.