mirror of
https://github.com/c-cube/moonpool.git
synced 2025-12-06 11:15:38 -05:00
add Fut.{cancel,try_cancel}
This commit is contained in:
parent
213d9bdd19
commit
eba239487c
2 changed files with 11 additions and 0 deletions
|
|
@ -15,6 +15,8 @@ let make () =
|
|||
fut, fut
|
||||
|
||||
let[@inline] return x : _ t = C.returned x
|
||||
let[@inline] cancel x ebt = C.cancel x (fst ebt) (snd ebt)
|
||||
let[@inline] try_cancel x ebt = C.try_cancel x (fst ebt) (snd ebt)
|
||||
|
||||
let[@inline] fail exn bt : _ t =
|
||||
let fut = C.create () in
|
||||
|
|
|
|||
|
|
@ -51,6 +51,15 @@ val on_result_ignore : _ t -> (Exn_bt.t option -> unit) -> unit
|
|||
|
||||
exception Already_fulfilled
|
||||
|
||||
val try_cancel : _ promise -> Exn_bt.t -> bool
|
||||
(** [try_cancel promise ebt] tries to cancel the promise, returning [true]. It
|
||||
returns [false] if the promise is already resolved.
|
||||
@since NEXT_RELEASE *)
|
||||
|
||||
val cancel : _ promise -> Exn_bt.t -> unit
|
||||
(** Silent version of {!try_cancel}, ignoring the result.
|
||||
@since NEXT_RELEASE *)
|
||||
|
||||
val fulfill : 'a promise -> 'a or_error -> unit
|
||||
(** Fullfill the promise, setting the future at the same time.
|
||||
@raise Already_fulfilled if the promise is already fulfilled. *)
|
||||
|
|
|
|||
Loading…
Add table
Reference in a new issue