Module Lwt_main


module Lwt_main: sig .. end
Main loop and event queue


This module controls the ``main-loop'' of Lwt.
val run : 'a Lwt.t -> 'a
run t calls the Lwt scheduler repeatedly until t terminates, then returns the value returned by the thread. It t fails with an exception, this exception is raised.

Note that you should avoid using run inside threads


val exit_hooks : (unit -> unit Lwt.t) Lwt_sequence.t
Sets of functions executed just before the program exit.

Notes:



Low-level control of event loop


The rest of this file is for advanced users. You must have a good understanding on how Lwt works to use it.

This part has two purpose:


type fd_set = Unix.file_descr list 
A set of file-descriptors
type current_time = float Lazy.t 
The current time. It is a lazy value to avoid a call to Unix.gettimeofday if not needed.
type select = fd_set ->
fd_set ->
fd_set ->
float option ->
current_time * fd_set * fd_set * fd_set
Type of a select-like function
val select_filters : (current_time -> select -> select) Lwt_sequence.t
The set of all select filters.
val apply_filters : select -> select
apply_filters select apply all the filters on the given select function.
val default_select : select
The default select function. It uses Unix.select.
val default_iteration : unit -> unit
The default iteration function. It just apply all select filters on default_select, the, call the resulting select function.
val main_loop_iteration : (unit -> unit) Pervasives.ref
The function doing one step of the main loop.

Utils

val min_timeout : float option -> float option -> float option
min_timeout a b returns the smallest timeout of two timeouts.