Module IO_lwt.Future

type 'a t = 'a Lwt.t

Future value

type 'a promise = 'a Lwt.u

How to fill an existing future with a value

val fullfill : 'a promise -> 'a -> unit

Fill a promise with a value. Behavior is not specified if this is called several times

val cancel : _ t -> unit

Cancel a future. Does nothing if the promise is filled already or if there's no meaningful notion of cancellation.

val make : ?⁠on_cancel:(unit -> unit) -> unit -> 'a t * 'a promise

Make a future with the accompanying promise to fullfill it.

parameter on_cancel

if provided, call this function upon cancellation.

type 'a wait = 'a t
val wait : 'a t -> 'a wait

Wait for the future to be filled