11(* * Work-stealing thread pool.
22
33 A pool of threads with a worker-stealing scheduler. The pool contains a
4- fixed number of threads that wait for work items to come, process these, and
5- loop.
4+ fixed number of worker threads that wait for work items to come, process
5+ these, and loop.
66
77 This is good for CPU-intensive tasks that feature a lot of small tasks. Note
88 that tasks will not always be processed in the order they are scheduled, so
1515 in it to stop (after they finish their work), and wait for them to stop.
1616
1717 The threads are distributed across a fixed domain pool (whose size is
18- determined by {!Domain.recommended_domain_count} on OCaml 5, and simply the
19- single runtime on OCaml 4) . *)
18+ determined by {!Domain.recommended_domain_count}. See {!create} for more
19+ details . *)
2020
2121include module type of Runner
2222
@@ -36,8 +36,14 @@ val create : (unit -> t, _) create_args
3636 @param num_threads
3737 size of the pool, ie. number of worker threads. It will be at least [1]
3838 internally, so [0] or negative values make no sense. The default is
39- [Domain.recommended_domain_count()], ie one worker thread per CPU core. On
40- OCaml 4 the default is [4] (since there is only one domain).
39+ [Domain.recommended_domain_count()], ie one worker thread per CPU core.
40+
41+ Note that specifying [num_threads=n] means that the degree of parallelism is
42+ at most [n]. This behavior is different than the one of [Domainslib], see
43+ https://github.com/c-cube/moonpool/issues/41 for context.
44+
45+ If you want to use all cores, use [Domain.recommended_domain_count()].
46+
4147 @param on_exit_thread called at the end of each thread in the pool
4248 @param name
4349 a name for this thread pool, used if tracing is enabled (since 0.6) *)
0 commit comments