Module Lwt_engine
Contents
Instructions: Use this module in your project
In the IDE (CLion, Visual Studio Code, Xcode, etc.) you use for your DkSDK project:
Add the following to your project's
dependencies/CMakeLists.txt:DkSDKProject_DeclareAvailable(lwt CONSTRAINT "= 5.6.1" FINDLIBS lwt lwt.unix) DkSDKProject_MakeAvailable(lwt)Add the
Findlib::lwtlibrary to any desired targets insrc/*/CMakeLists.txt:target_link_libraries(YourPackage_YourLibraryName # ... existing libraries, if any ... Findlib::lwt)Click your IDE's
Buildbutton
Not using DkSDK?
FIRST, do one or all of the following:
Run:
opam install lwt.5.6.1Edit your
dune-projectand add:(package (name YourExistingPackage) (depends ; ... existing dependenices ... (lwt (>= 5.6.1))))Then run:
dune build *.opam # if this fails, run: dune buildEdit your
<package>.opamfile and add:depends: [ # ... existing dependencies ... "lwt" {>= "5.6.1"} ]Then run:
opam install . --deps-only
FINALLY, add the lwt.unix library to any desired (library)and/or (executable) targets in your **/dune files:
(library
(name YourLibrary)
; ... existing library options ...
(libraries
; ... existing libraries ...
lwt.unix))
(executable
(name YourExecutable)
; ... existing executable options ...
(libraries
; ... existing libraries ...
lwt.unix))Events
typeevent
Type of events. An event represent a callback registered to be called when some event occurs.
valstop_event :event->unit
stop_event event stops the given event.
valfake_event :event
Event which does nothing when stopped.
Event loop functions
valiter : ``bool->unit
iter block performs one iteration of the main loop. If block is
true the function must block until one event becomes available,
otherwise it should just check for available events and return
immediately.
valon_readable :Unix.file_descr->``(event->unit)``->event
on_readable fd f calls f each time fd becomes readable.
valon_writable :Unix.file_descr->``(event->unit)``->event
on_readable fd f calls f each time fd becomes writable.
on_timer delay repeat f calls f one time after delay seconds. If
repeat is true then f is called each delay seconds, otherwise it
is called only one time.
valreadable_count : ``unit->int
Returns the number of events waiting for a file descriptor to become readable.
valwritable_count : ``unit->int
Returns the number of events waiting for a file descriptor to become writable.
valtimer_count : ``unit->int
Returns the number of registered timers.
valfake_io :Unix.file_descr->unit
Simulates activity on the given file descriptor.
valfork : ``unit->unit
Called internally by Lwt_unix.fork to make sure we don't get strange behaviour
Engines
An engine represents a set of functions used to register different kinds of callbacks for different kinds of events.
classvirtualabstract:object...end
Abstract class for engines.
classtypet=object...end
Type of engines.
Predefined engines
typeev_loop
moduleEv_backend:sig...end
Type of libev loops.
classlibev: ``?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.
Engine based on Unix.select.
classvirtualselect_based:object...end
Abstract class for engines based on a select-like function.
classvirtualpoll_based:object...end
Abstract class for engines based on a poll-like function.
The current engine
valget : ``unit->t
get () returns the engine currently in use.
valset : ``?transfer:bool->``?destroy:bool->t->unit
set ?transfer ?destroy engine replaces the current engine by the given
one.
If transfer is true (the default) all events from the current engine
are transferred to the new one.
If destroy is true (the default) then the current engine is
destroyed before being replaced.
moduleVersioned:sig...end
