mirror of
https://github.com/c-cube/moonpool.git
synced 2025-12-06 03:05:30 -05:00
more internal refactor
This commit is contained in:
parent
cc8860c6e3
commit
b0fe279f42
9 changed files with 11 additions and 11 deletions
|
|
@ -3,7 +3,7 @@
|
||||||
(name moonpool)
|
(name moonpool)
|
||||||
(libraries moonpool.private)
|
(libraries moonpool.private)
|
||||||
(flags :standard -open Moonpool_private)
|
(flags :standard -open Moonpool_private)
|
||||||
(private_modules d_pool_)
|
(private_modules domain_pool_)
|
||||||
(preprocess
|
(preprocess
|
||||||
(action
|
(action
|
||||||
(run %{project_root}/src/cpp/cpp.exe %{input-file}))))
|
(run %{project_root}/src/cpp/cpp.exe %{input-file}))))
|
||||||
|
|
|
||||||
|
|
@ -87,7 +87,7 @@ let create ?(on_init_thread = default_thread_init_exit_)
|
||||||
| None -> AT_pair (ignore, fun _ _ -> ())
|
| None -> AT_pair (ignore, fun _ _ -> ())
|
||||||
in
|
in
|
||||||
|
|
||||||
let num_domains = D_pool_.n_domains () in
|
let num_domains = Domain_pool_.n_domains () in
|
||||||
|
|
||||||
(* number of threads to run *)
|
(* number of threads to run *)
|
||||||
let num_threads = Util_pool_.num_threads ?num_threads () in
|
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 *)
|
(* now run the main loop *)
|
||||||
Fun.protect run ~finally:(fun () ->
|
Fun.protect run ~finally:(fun () ->
|
||||||
(* on termination, decrease refcount of underlying domain *)
|
(* 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 ()
|
on_exit_thread ~dom_id:dom_idx ~t_id ()
|
||||||
in
|
in
|
||||||
|
|
||||||
|
|
@ -148,7 +148,7 @@ let create ?(on_init_thread = default_thread_init_exit_)
|
||||||
Bb_queue.push receive_threads (i, thread)
|
Bb_queue.push receive_threads (i, thread)
|
||||||
in
|
in
|
||||||
|
|
||||||
D_pool_.run_on dom_idx create_thread_in_domain
|
Domain_pool_.run_on dom_idx create_thread_in_domain
|
||||||
in
|
in
|
||||||
|
|
||||||
(* start all threads, placing them on the domains
|
(* start all threads, placing them on the domains
|
||||||
|
|
|
||||||
|
|
@ -110,7 +110,7 @@ let for_ ?chunk_size n (f : int -> int -> unit) : unit =
|
||||||
| Some cs -> max 1 (min n cs)
|
| Some cs -> max 1 (min n cs)
|
||||||
| None ->
|
| None ->
|
||||||
(* guess: try to have roughly one task per core *)
|
(* 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
|
in
|
||||||
|
|
||||||
let start_tasks ~name ~run (suspension : Suspend_.suspension) =
|
let start_tasks ~name ~run (suspension : Suspend_.suspension) =
|
||||||
|
|
|
||||||
|
|
@ -1,6 +1,6 @@
|
||||||
let start_thread_on_some_domain f x =
|
let start_thread_on_some_domain f x =
|
||||||
let did = Random.int (D_pool_.n_domains ()) in
|
let did = Random.int (Domain_pool_.n_domains ()) in
|
||||||
D_pool_.run_on_and_wait did (fun () -> Thread.create f x)
|
Domain_pool_.run_on_and_wait did (fun () -> Thread.create f x)
|
||||||
|
|
||||||
let run_async = Runner.run_async
|
let run_async = Runner.run_async
|
||||||
let recommended_thread_count () = Domain_.recommended_number ()
|
let recommended_thread_count () = Domain_.recommended_number ()
|
||||||
|
|
|
||||||
|
|
@ -1,5 +1,5 @@
|
||||||
let num_threads ?num_threads () : int =
|
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 *)
|
(* number of threads to run *)
|
||||||
let num_threads =
|
let num_threads =
|
||||||
|
|
|
||||||
|
|
@ -262,7 +262,7 @@ let create ?(on_init_thread = default_thread_init_exit_)
|
||||||
| None -> AT_pair (ignore, fun _ _ -> ())
|
| None -> AT_pair (ignore, fun _ _ -> ())
|
||||||
in
|
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
|
let num_threads = Util_pool_.num_threads ?num_threads () in
|
||||||
|
|
||||||
(* make sure we don't bias towards the first domain(s) in {!D_pool_} *)
|
(* 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 *)
|
(* now run the main loop *)
|
||||||
Fun.protect run ~finally:(fun () ->
|
Fun.protect run ~finally:(fun () ->
|
||||||
(* on termination, decrease refcount of underlying domain *)
|
(* 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 ()
|
on_exit_thread ~dom_id:dom_idx ~t_id ()
|
||||||
in
|
in
|
||||||
|
|
||||||
|
|
@ -342,7 +342,7 @@ let create ?(on_init_thread = default_thread_init_exit_)
|
||||||
Bb_queue.push receive_threads (i, thread)
|
Bb_queue.push receive_threads (i, thread)
|
||||||
in
|
in
|
||||||
|
|
||||||
D_pool_.run_on dom_idx create_thread_in_domain
|
Domain_pool_.run_on dom_idx create_thread_in_domain
|
||||||
in
|
in
|
||||||
|
|
||||||
(* start all threads, placing them on the domains
|
(* start all threads, placing them on the domains
|
||||||
|
|
|
||||||
Loading…
Add table
Reference in a new issue