Module Lwt_engine
Lwt unix main loop engine
Events
type event
Type of events. An event represent a callback registered to be called when some event occurs.
val stop_event : event -> unit
stop_event event
stops the given event.
val fake_event : event
Event which does nothing when stopped.
Event loop functions
val iter : bool -> unit
iter block
performs one iteration of the main loop. Ifblock
istrue
the 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) -> event
on_readable fd f
callsf
each timefd
becomes readable.
val on_writable : Unix.file_descr -> (event -> unit) -> event
on_readable fd f
callsf
each timefd
becomes writable.
val on_timer : float -> bool -> (event -> unit) -> event
on_timer delay repeat f
callsf
one time afterdelay
seconds. Ifrepeat
istrue
thenf
is called eachdelay
seconds, otherwise it is called only one time.
val readable_count : unit -> int
Returns the number of events waiting for a file descriptor to become readable.
Engines
class virtual abstract : object ... end
Abstract class for engines.
class type t = object ... end
Type of engines.
Predefined engines
module Ev_backend : sig ... end
class libev : ?backend:Ev_backend.t -> unit -> object ... end
Engine 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 ... end
Abstract class for engines based on a select-like function.
class virtual poll_based : object ... end
Abstract class for engines based on a poll-like function.
The current engine
val get : unit -> t
get ()
returns the engine currently in use.
val set : ?transfer:bool -> ?destroy:bool -> t -> unit
set ?transfer ?destroy engine
replaces the current engine by the given one.If
transfer
istrue
(the default) all events from the current engine are transferred to the new one.If
destroy
istrue
(the default) then the current engine is destroyed before being replaced.
module Versioned : sig ... end