Module Eio.Time

Clocks, time, sleeping and timeouts.

class virtual clock : object ... end
val now : clock -> float

now t is the current time according to t.

val sleep_until : clock -> float -> unit

sleep_until t time waits until the given time is reached.

val sleep : clock -> float -> unit

sleep t d waits for d seconds.

val with_timeout : clock -> float -> ( unit -> ( 'a, 'e ) Stdlib.result ) -> ( 'a, [> `Timeout ] as 'e ) Stdlib.result

with_timeout clock d fn runs fn () but cancels it after d seconds.

exception Timeout
val with_timeout_exn : clock -> float -> ( unit -> 'a ) -> 'a

with_timeout_exn clock d fn runs fn () but cancels it after d seconds, raising exception Timeout.