package lwt

  1. Overview
  2. Docs
Promises and event-driven I/O

Install

Dune Dependency

Authors

Maintainers

Sources

5.7.0.tar.gz
md5=737039d29d45b2d2b35db6931c8d75c6
sha512=42e629920783428673b99c9d7a639237c9e6b35079b5d907bc67e7ea506acf9edadc48cec580bdcfd2410ed9412bf5e6bcc8b09de2fa7d35ce1490973d05ddd1

doc/lwt.unix/Lwt_timeout/index.html

Module Lwt_timeoutSource

Cancelable timeouts.

Sourcetype t
Sourceval create : int -> (unit -> unit) -> t

Lwt_timeout.create n f creates a new timeout object with duration n seconds. f is the action, a function to be called once the timeout expires. f should not raise exceptions.

The timeout is not started until Lwt_timeout.start is called on it.

Sourceval start : t -> unit

Starts 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 timeout with 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. Calling Lwt_timeout.start timeout at this point cancels this upcoming action call, and schedules a call three seconds from now.

Sourceval stop : t -> unit

Stops (cancels) the given timeout.

Sourceval change : t -> int -> unit

Changes 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.start works on a timeout that has already been started.

Sourceval set_exn_handler : (exn -> unit) -> unit

Lwt_timeout.set_exn_handler f sets 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 exception exn despite this, f exn is called.

The default behavior of f exn, set by Lwt_timeout on program startup, is to pass exn to !Lwt.async_exception_hook. The default behavior of that is to terminate the process.

OCaml

Innovation. Community. Security.