package octez-libs

  1. Overview
  2. Docs
A package that contains multiple base libraries used by the Octez suite

Install

Dune Dependency

Authors

Maintainers

Sources

octez-19.1.tar.gz
sha256=55ea1fb8bb3273a7fc270ca8f650d45c56449665619482aad9bc12f3ea736b7e
sha512=fec850fc2d17d7490bbabd5147d62aad13b3aaed8774270f8a38ab419670ed03e0fd30cf8642a97984eca5c2446726fe590ad99c015f7ec50919dc7652f25053

doc/octez-libs.stdlib/Tezos_stdlib/Lwt_utils/index.html

Module Tezos_stdlib.Lwt_utilsSource

Sourceexception None_successful of string
Sourceval never_ending : unit -> 'a Lwt.t
Sourceval worker : string -> on_event:(string -> [ `Ended | `Failed of string | `Started ] -> unit Lwt.t) -> run:(unit -> unit Lwt.t) -> cancel:(unit -> unit Lwt.t) -> unit Lwt.t

worker name ~on_event ~run ~cancel internally calls run () (which returns a promise p) and returns its own promise work. If p becomes fulfilled, then work also becomes fulfilled. If p becomes rejected then cancel () is called and, once its promise is resolved, work is fulfilled. This gives the opportunity for the function cancel to clean-up some resources.

The function on_event is called at different times (start, failure, end) and is mostly meant as a logging mechanism but can also be used for other purposes such as synchronization between different workers.

If the promises returned by on_event or cancel raise an exception or become rejected, the exception/failure is simply ignored and the promise is treated as having resolved anyway.

Note that the promise work returned by the worker function is not cancelable. If you need to cancel the promise returned by run, you need to embed your own synchronization system within run. E.g.,

let p, r = Lwt.wait in let run () = let main = … in Lwt.pick [main ; p] in

Sourceval pick_successful : 'a Lwt.t list -> 'a Lwt.t

pick_successful promises succeeds when it picks the first successful promise. On finding a successful promise, an attempt will be made to cancel all pending promises.

OCaml

Innovation. Community. Security.