add Moonpool_lwt.spawn_lwt_ignore

This commit is contained in:
Simon Cruanes 2025-09-08 10:49:11 -04:00
parent 2aabc30b70
commit f245f4913c
No known key found for this signature in database
GPG key ID: EBFFF6F283F3A2B4
2 changed files with 5 additions and 0 deletions

View file

@ -306,6 +306,8 @@ let spawn_lwt f : _ Lwt.t =
with exn -> Lwt.wakeup_exn lwt_prom exn); with exn -> Lwt.wakeup_exn lwt_prom exn);
lwt_fut lwt_fut
let spawn_lwt_ignore f = ignore (spawn_lwt f : unit Lwt.t)
let lwt_main (f : _ -> 'a) : 'a = let lwt_main (f : _ -> 'a) : 'a =
let st = setup () in let st = setup () in
(* make sure to cleanup *) (* make sure to cleanup *)

View file

@ -27,6 +27,9 @@ val spawn_lwt : (unit -> 'a) -> 'a Lwt.t
(** This spawns a task that runs in the Lwt scheduler. (** This spawns a task that runs in the Lwt scheduler.
@raise Failure if {!lwt_main} was not called. *) @raise Failure if {!lwt_main} was not called. *)
val spawn_lwt_ignore : (unit -> unit) -> unit
(** Like {!spawn_lwt} but ignores the result, like [Lwt.async]. *)
val await_lwt : 'a Lwt.t -> 'a val await_lwt : 'a Lwt.t -> 'a
(** [await_lwt fut] awaits a Lwt future from inside a task running on a moonpool (** [await_lwt fut] awaits a Lwt future from inside a task running on a moonpool
runner. This must be run from within a Moonpool runner so that the await-ing runner. This must be run from within a Moonpool runner so that the await-ing