fix: make Moonpool_lwt.fut_of_lwt idempotent
Some checks failed
github pages / Deploy doc (push) Has been cancelled
Build and Test / build (push) Has been cancelled
Build and Test / build-compat (push) Has been cancelled
Build and Test / format (push) Has been cancelled

this way the resulting future can be cancelled/fulfilled from
the outside without crashing Lwt
This commit is contained in:
Simon Cruanes 2025-10-07 13:53:04 -04:00
parent 538f3df31a
commit 92300ad698
No known key found for this signature in database
GPG key ID: EBFFF6F283F3A2B4

View file

@ -142,10 +142,10 @@ end
(** Resolve [prom] with the result of [lwt_fut] *)
let transfer_lwt_to_fut (lwt_fut : 'a Lwt.t) (prom : 'a Fut.promise) : unit =
Lwt.on_any lwt_fut
(fun x -> M.Fut.fulfill prom (Ok x))
(fun x -> M.Fut.fulfill_idempotent prom (Ok x))
(fun exn ->
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)
(tr : M.Trigger.t) : unit =