Module Lwt_timeout
Cancelable timeouts.
val create : int -> (unit -> unit) -> tLwt_timeout.create n fcreates a new timeout object with durationnseconds.fis the action, a function to be called once the timeout expires.fshould not raise exceptions.The timeout is not started until
Lwt_timeout.startis called on it.
val start : t -> unitStarts the given timeout.
Starting a timeout that has already been started has the same effect as stopping it, and then restarting it with its original duration. So, suppose you have
timeoutwith a duration of three seconds, which was started two seconds ago. The next call to its action is scheduled for one second in the future. CallingLwt_timeout.start timeoutat this point cancels this upcoming action call, and schedules a call three seconds from now.
val stop : t -> unitStops (cancels) the given timeout.
val change : t -> int -> unitChanges the duration of the given timeout.
If the timeout has already been started, it is stopped, and restarted with its new duration. This is similar to how
Lwt_timeout.startworks on a timeout that has already been started.
val set_exn_handler : (exn -> unit) -> unitLwt_timeout.set_exn_handler fsets the handler to be used for exceptions raised by timeout actions. Recall that actions are not allowed to raise exceptions. If they do raise an exceptionexndespite this,f exnis called.The default behavior of
f exn, set byLwt_timeouton program startup, is to passexnto!Lwt.async_exception_hook. The default behavior of that is to terminate the process.