Compare commits

...

4 commits

Author SHA1 Message Date
Simon Cruanes
5e2334517f
Merge a6e59522ed into 867cbd2318 2025-09-08 19:46:56 +00:00
Simon Cruanes
a6e59522ed
detail 2025-09-08 15:46:48 -04:00
Simon Cruanes
97ee41287f
add Moonpool_lwt.on_lwt_thread 2025-09-08 15:46:26 -04:00
Simon Cruanes
a144bf0668
add Moonpool_lwt.spawn_lwt_ignore 2025-09-08 10:49:11 -04:00
3 changed files with 11 additions and 1 deletions

View file

@ -306,6 +306,9 @@ let spawn_lwt f : _ Lwt.t =
with exn -> Lwt.wakeup_exn lwt_prom exn);
lwt_fut
let spawn_lwt_ignore f = ignore (spawn_lwt f : unit Lwt.t)
let on_lwt_thread = Main_state.on_lwt_thread
let lwt_main (f : _ -> 'a) : 'a =
let st = setup () in
(* 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.
@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
(** [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
@ -42,6 +45,11 @@ val lwt_main : (Moonpool.Runner.t -> 'a) -> 'a
(** [lwt_main f] sets the moonpool-lwt bridge up, runs lwt main, calls [f],
destroys the bridge, and return the result of [f()]. *)
val on_lwt_thread : unit -> bool
(** [on_lwt_thread ()] is true if the current thread is the one currently
running {!lwt_main}.
@raise Failure if {!lwt_main} was not called. *)
val lwt_main_runner : unit -> Moonpool.Runner.t
(** The runner from {!lwt_main}. The runner is only going to work if {!lwt_main}
is currently running in some thread.

View file

@ -1,4 +1,3 @@
open! Moonpool
module M_lwt = Moonpool_lwt
let ( let@ ) = ( @@ )