add Moonpool.run_async

This commit is contained in:
Simon Cruanes 2023-10-29 17:11:48 -04:00
parent 72f289af84
commit 2073c600c4
2 changed files with 7 additions and 0 deletions

View file

@ -2,6 +2,7 @@ let start_thread_on_some_domain f x =
let did = Random.int (D_pool_.n_domains ()) in let did = Random.int (D_pool_.n_domains ()) in
D_pool_.run_on_and_wait did (fun () -> Thread.create f x) D_pool_.run_on_and_wait did (fun () -> Thread.create f x)
let run_async = Runner.run_async
let recommended_thread_count () = Domain_.recommended_number () let recommended_thread_count () = Domain_.recommended_number ()
let spawn = Fut.spawn let spawn = Fut.spawn

View file

@ -23,6 +23,12 @@ val start_thread_on_some_domain : ('a -> unit) -> 'a -> Thread.t
to run the thread. This ensures that we don't always pick the same domain to run the thread. This ensures that we don't always pick the same domain
to run all the various threads needed in an application (timers, event loops, etc.) *) to run all the various threads needed in an application (timers, event loops, etc.) *)
val run_async : Runner.t -> (unit -> unit) -> unit
(** [run_async runner task] schedules the task to run
on the given runner. This means [task()] will be executed
at some point in the future, possibly in another thread.
@since NEXT_RELEASE *)
val recommended_thread_count : unit -> int val recommended_thread_count : unit -> int
(** Number of threads recommended to saturate the CPU. (** Number of threads recommended to saturate the CPU.
For IO pools this makes little sense (you might want more threads than For IO pools this makes little sense (you might want more threads than