Lwt - API Reference ¶
Core library ¶
The core library (lwt package) contains the Lwt module, which defines cooperative threads with all the primitives to manipulate them. It also provides several general purpose modules, which do not depend on any external package.
Module Lwt: cooperative light-weight threads.
Cooperative locks for mutual exclusion
Creating pools (for example pools of connections to a database).
Mutable sequence of elements
Unix bindings ¶
The lwt.unix package provides:
- the Lwt_unix module, which wrap system calls into cooperative ones
- the Lwt_io module, which defines cooperative byte channel, in replacement of ones of the standard library
- module helpers for logging, spawning processes, ...
Interaction with the garbage collector
Buffered byte channels
Main loop and event queue
Lwt unix main loop engine
Cooperative system calls
This package depends on the core library and the unix package.
Reactive programming helpers ¶
The lwt.react package provides helpers for functionnal reactive programming with Lwt. It is based on the react package. The Lwt_react module is a replacement for the React module. It contains:
- all the functions of the React module
- Lwt specific primitives
- cooperative versions of react functions
This package depends on the core library and the react package.
Syntax extensions ¶
Lwt is shipped with two syntax extensions. The first one, contained in the lwt.syntax package, aims to make coding with Lwt easier, and to make code more readable. The second, contained in the package lwt.syntax.log, is a camlp4 filter which decreases the performance penalty when using logging by inlining level tests.
Syntactic sugars for lwt
Terminal manipulation ¶
The package lwt.text provides:
- terminal manipulation through the module Lwt_term
- text channels which behaves as byte channels but are aware of the text encoding
- a cooperative, fully customizable read-line facility
Interactive line input
This package depends on the core library, and the lwt.react, lwt.unix, text packages.
The following modules are wrapper for integration of non-Lwt functions/packages into Lwt.
Cooperative unix system calls
This module allows to mix preemptive threads with Lwt cooperative threads.