mirror of
https://github.com/c-cube/moonpool.git
synced 2025-12-06 03:05:30 -05:00
fix: make Moonpool_lwt.fut_of_lwt idempotent
this way the resulting future can be cancelled/fulfilled from the outside without crashing Lwt
This commit is contained in:
parent
538f3df31a
commit
92300ad698
1 changed files with 2 additions and 2 deletions
|
|
@ -142,10 +142,10 @@ end
|
||||||
(** Resolve [prom] with the result of [lwt_fut] *)
|
(** Resolve [prom] with the result of [lwt_fut] *)
|
||||||
let transfer_lwt_to_fut (lwt_fut : 'a Lwt.t) (prom : 'a Fut.promise) : unit =
|
let transfer_lwt_to_fut (lwt_fut : 'a Lwt.t) (prom : 'a Fut.promise) : unit =
|
||||||
Lwt.on_any lwt_fut
|
Lwt.on_any lwt_fut
|
||||||
(fun x -> M.Fut.fulfill prom (Ok x))
|
(fun x -> M.Fut.fulfill_idempotent prom (Ok x))
|
||||||
(fun exn ->
|
(fun exn ->
|
||||||
let bt = Printexc.get_callstack 10 in
|
let bt = Printexc.get_callstack 10 in
|
||||||
M.Fut.fulfill prom (Error (Exn_bt.make exn bt)))
|
M.Fut.fulfill_idempotent prom (Error (Exn_bt.make exn bt)))
|
||||||
|
|
||||||
let[@inline] register_trigger_on_lwt_termination (lwt_fut : _ Lwt.t)
|
let[@inline] register_trigger_on_lwt_termination (lwt_fut : _ Lwt.t)
|
||||||
(tr : M.Trigger.t) : unit =
|
(tr : M.Trigger.t) : unit =
|
||||||
|
|
|
||||||
Loading…
Add table
Reference in a new issue