Module Moonpool_lwt.IO

IO using the Lwt event loop.

These IO operations work on non-blocking file descriptors and rely on a Lwt_engine event loop being active (meaning, Lwt_main.run is currently running in some thread).

Calling these functions must be done from a moonpool runner. A function like read will first try to perform the IO action directly (here, call Unix.read); if the action fails because the FD is not ready, then await_readable is called: it suspends the fiber and subscribes it to Lwt to be awakened when the FD becomes ready.

val read : Unix.file_descr -> bytes -> int -> int -> int

Read from the file descriptor

val await_readable : Unix.file_descr -> unit

Suspend the fiber until the FD is readable

val write_once : Unix.file_descr -> bytes -> int -> int -> int

Perform one write into the file descriptor

val await_writable : Unix.file_descr -> unit

Suspend the fiber until the FD is writable

val write : Unix.file_descr -> bytes -> int -> int -> unit

Loop around write_once to write the entire slice.

val sleep_s : float -> unit

Suspend the fiber for n seconds.