add Moonpool_lwt.on_lwt_thread

This commit is contained in:
Simon Cruanes 2025-09-08 15:46:26 -04:00
parent f245f4913c
commit 8bd79c70b5
No known key found for this signature in database
GPG key ID: EBFFF6F283F3A2B4
2 changed files with 6 additions and 0 deletions

View file

@ -307,6 +307,7 @@ let spawn_lwt f : _ Lwt.t =
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

View file

@ -45,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.