Module Lwt_engine
Lwt unix main loop engine
Events
type eventType of events. An event represent a callback registered to be called when some event occurs.
val stop_event : event -> unitstop_event eventstops the given event.
val fake_event : eventEvent which does nothing when stopped.
Event loop functions
val iter : bool -> unititer blockperforms one iteration of the main loop. Ifblockistruethe function must block until one event becomes available, otherwise it should just check for available events and return immediately.
val on_readable : Unix.file_descr -> (event -> unit) -> eventon_readable fd fcallsfeach timefdbecomes readable.
val on_writable : Unix.file_descr -> (event -> unit) -> eventon_readable fd fcallsfeach timefdbecomes writable.
val on_timer : float -> bool -> (event -> unit) -> eventon_timer delay repeat fcallsfone time afterdelayseconds. Ifrepeatistruethenfis called eachdelayseconds, otherwise it is called only one time.
val readable_count : unit -> intReturns the number of events waiting for a file descriptor to become readable.
Engines
class virtual abstract : object ... endAbstract class for engines.
class type t = object ... endType of engines.
Predefined engines
module Ev_backend : sig ... endclass libev : ?backend:Ev_backend.t -> unit -> object ... endEngine based on libev. If not compiled with libev support, the creation of the class will raise
Lwt_sys.Not_available.
class virtual select_based : object ... endAbstract class for engines based on a select-like function.
class virtual poll_based : object ... endAbstract class for engines based on a poll-like function.
The current engine
val get : unit -> tget ()returns the engine currently in use.
val set : ?transfer:bool -> ?destroy:bool -> t -> unitset ?transfer ?destroy enginereplaces the current engine by the given one.If
transferistrue(the default) all events from the current engine are transferred to the new one.If
destroyistrue(the default) then the current engine is destroyed before being replaced.
module Versioned : sig ... end