mirror of
https://github.com/c-cube/moonpool.git
synced 2025-12-06 03:05:30 -05:00
risk is a tight loop of `Pool.with_`, where by not waiting for the pool to entirely shutdown (including the domains, potentially) we risk running out of domains in the next iterations.
25 lines
939 B
OCaml
25 lines
939 B
OCaml
(** Static pool of domains.
|
|
|
|
These domains are shared between {b all} the pools in moonpool.
|
|
The rationale is that we should not have more domains than cores, so
|
|
it's easier to pre-allocate exactly that many domains, and run more flexible
|
|
thread pools on top.
|
|
*)
|
|
|
|
type domain = Domain_.t
|
|
|
|
val n_domains : unit -> int
|
|
(** Number of domains in the pool *)
|
|
|
|
val run_on : int -> (unit -> unit) -> unit
|
|
(** [run_on i f] runs [f()] on the domain with index [i].
|
|
Precondition: [0 <= i < n_domains()] *)
|
|
|
|
val decr_on : int -> domain_to_join:(Domain_.t -> unit) -> unit
|
|
(** Signal that a thread is stopping on the domain with index [i].
|
|
@param domain_to_join called with a domain if this domain shuts down
|
|
because no one is using it anymore *)
|
|
|
|
val run_on_and_wait : int -> (unit -> 'a) -> 'a
|
|
(** [run_on_and_wait i f] runs [f()] on the domain with index [i],
|
|
and blocks until the result of [f()] is returned back. *)
|