Kcas_data.PromiseA promise of a value to be resolved at some point in the future.
Example:
# let promise, resolver = Promise.create () in
let domain = Domain.spawn @@ fun () ->
Printf.printf "Got %d\n%!" (Promise.await promise)
in
Promise.resolve resolver 42;
Domain.join domain
Got 42
- : unit = ()type 'a or_exn = ('a, exn) Stdlib.result tThe type of a promise of a result of type ('a, exn) result.
create () returns a new unresolved pair of a promise and a resolver for the promise.
val create_resolved : 'a -> 'a tcreate_resolved x returns a promise that is already resolved to the given value x.
module Xt : sig ... endExplicit transaction log passing on promises.
val resolve : 'a u -> 'a -> unitresolve u v resolves the promise corresponding to the resolver u to the value v. Any awaiters of the corresponding promise are then unblocked.
val await : ?timeoutf:float -> 'a t -> 'aawait t either immediately returns the resolved value of the promise t or blocks until the promise t is resolved.
val peek : 'a t -> 'a optionpeek t immediately returns either the resolved value of the promise t or None in case the promise hasn't yet been resolved.
val is_resolved : 'a t -> boolis_resolved t determines whether the promise t has already been resolved.
val await_exn : ?timeoutf:float -> 'a or_exn -> 'aawait_exn t is equivalent to match await t with v -> v | exception e -> raise e.
val resolve_ok : ('a, 'b) Stdlib.result u -> 'a -> unitresolve_ok u v is equivalent to resolve u (Ok v).
val resolve_error : ('a, 'b) Stdlib.result u -> 'b -> unitresolve_error u e is equivalent to resolve u (Error e).