mirror of
https://github.com/c-cube/moonpool.git
synced 2025-12-14 14:56:17 -05:00
Compare commits
3 commits
f041520b82
...
a6e59522ed
| Author | SHA1 | Date | |
|---|---|---|---|
|
|
a6e59522ed | ||
|
|
97ee41287f | ||
|
|
a144bf0668 |
3 changed files with 11 additions and 1 deletions
|
|
@ -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 *)
|
||||
|
|
|
|||
|
|
@ -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.
|
||||
|
|
|
|||
|
|
@ -1,4 +1,3 @@
|
|||
open! Moonpool
|
||||
module M_lwt = Moonpool_lwt
|
||||
|
||||
let ( let@ ) = ( @@ )
|
||||
|
|
|
|||
Loading…
Add table
Reference in a new issue