more internal refactor

This commit is contained in:
Simon Cruanes 2024-02-02 20:05:14 -05:00
parent cc8860c6e3
commit b0fe279f42
No known key found for this signature in database
GPG key ID: EBFFF6F283F3A2B4
9 changed files with 11 additions and 11 deletions

View file

@ -3,7 +3,7 @@
(name moonpool)
(libraries moonpool.private)
(flags :standard -open Moonpool_private)
(private_modules d_pool_)
(private_modules domain_pool_)
(preprocess
(action
(run %{project_root}/src/cpp/cpp.exe %{input-file}))))

View file

@ -87,7 +87,7 @@ let create ?(on_init_thread = default_thread_init_exit_)
| None -> AT_pair (ignore, fun _ _ -> ())
in
let num_domains = D_pool_.n_domains () in
let num_domains = Domain_pool_.n_domains () in
(* number of threads to run *)
let num_threads = Util_pool_.num_threads ?num_threads () in
@ -136,7 +136,7 @@ let create ?(on_init_thread = default_thread_init_exit_)
(* now run the main loop *)
Fun.protect run ~finally:(fun () ->
(* on termination, decrease refcount of underlying domain *)
D_pool_.decr_on dom_idx);
Domain_pool_.decr_on dom_idx);
on_exit_thread ~dom_id:dom_idx ~t_id ()
in
@ -148,7 +148,7 @@ let create ?(on_init_thread = default_thread_init_exit_)
Bb_queue.push receive_threads (i, thread)
in
D_pool_.run_on dom_idx create_thread_in_domain
Domain_pool_.run_on dom_idx create_thread_in_domain
in
(* start all threads, placing them on the domains

View file

@ -110,7 +110,7 @@ let for_ ?chunk_size n (f : int -> int -> unit) : unit =
| Some cs -> max 1 (min n cs)
| None ->
(* guess: try to have roughly one task per core *)
max 1 (1 + (n / D_pool_.n_domains ()))
max 1 (1 + (n / Domain_pool_.n_domains ()))
in
let start_tasks ~name ~run (suspension : Suspend_.suspension) =

View file

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

View file

@ -1,5 +1,5 @@
let num_threads ?num_threads () : int =
let n_domains = D_pool_.n_domains () in
let n_domains = Domain_pool_.n_domains () in
(* number of threads to run *)
let num_threads =

View file

@ -262,7 +262,7 @@ let create ?(on_init_thread = default_thread_init_exit_)
| None -> AT_pair (ignore, fun _ _ -> ())
in
let num_domains = D_pool_.n_domains () in
let num_domains = Domain_pool_.n_domains () in
let num_threads = Util_pool_.num_threads ?num_threads () in
(* make sure we don't bias towards the first domain(s) in {!D_pool_} *)
@ -330,7 +330,7 @@ let create ?(on_init_thread = default_thread_init_exit_)
(* now run the main loop *)
Fun.protect run ~finally:(fun () ->
(* on termination, decrease refcount of underlying domain *)
D_pool_.decr_on dom_idx);
Domain_pool_.decr_on dom_idx);
on_exit_thread ~dom_id:dom_idx ~t_id ()
in
@ -342,7 +342,7 @@ let create ?(on_init_thread = default_thread_init_exit_)
Bb_queue.push receive_threads (i, thread)
in
D_pool_.run_on dom_idx create_thread_in_domain
Domain_pool_.run_on dom_idx create_thread_in_domain
in
(* start all threads, placing them on the domains