Module Picos_lwt

Direct style Picos compatible interface to Lwt for OCaml 5.

This basically gives you an alternative direct style interface to programming with Lwt. All the scheduling decisions will be made by Lwt.

val await : (unit -> 'a Lwt.t) -> 'a

await thunk awaits for the promise returned by thunk () to resolve and returns the result. This should only be called from inside a fiber started through run.

val run : ?forbid:bool -> sleep:(float -> unit Lwt.t) -> (unit -> 'a) -> 'a Lwt.t

run ~sleep main runs the main program implemented in Picos as a promise with Lwt as the scheduler and given operation to sleep. In other words, the main program will be run as a Lwt promise or fiber.

Calling sleep seconds should return a cancelable promise that resolves after given number of seconds (unless canceled).

ℹī¸ Inside main you can use anything implemented in Picos for concurrent programming. In particular, you only need to call run with an implementation of sleep at the entry point of your application.

The optional forbid argument defaults to false and determines whether propagation of cancelation is initially allowed.

Functorized interface

A functor for building a Picos compatible direct style interface to Lwt with given implementation of sleep.

module type Sleep = sig ... end

Minimal signature for an implementation of sleep using Lwt.

module type S = sig ... end

Direct style Picos compatible interface to Lwt.

module Make (_ : Sleep) : S

Make (Sleep) creates a Picos compatible interface to Lwt with given implementation of sleep.