aboutsummaryrefslogtreecommitdiff
path: root/docs/src
diff options
context:
space:
mode:
authorBen Noordhuis <info@bnoordhuis.nl>2022-03-04 22:35:14 +0100
committerGitHub <noreply@github.com>2022-03-04 22:35:14 +0100
commitf250c6c73ee45aa93ec44133c9e0c635780ea741 (patch)
tree549fdf40ebe6b431c485c893a1d006d31cba79ee /docs/src
parentc40f8cb9f8ddf69d116952f8924a11ec0623b445 (diff)
downloadlibuv-f250c6c73ee45aa93ec44133c9e0c635780ea741.tar.gz
libuv-f250c6c73ee45aa93ec44133c9e0c635780ea741.zip
unix,win: add uv_available_parallelism() (#3499)
Replacement for the usage pattern where people use uv_cpu_info() as an imperfect heuristic for determining the amount of parallelism that is available to their programs. Fixes #3493.
Diffstat (limited to 'docs/src')
-rw-r--r--docs/src/misc.rst19
1 files changed, 19 insertions, 0 deletions
diff --git a/docs/src/misc.rst b/docs/src/misc.rst
index 38fbb560..bae44814 100644
--- a/docs/src/misc.rst
+++ b/docs/src/misc.rst
@@ -334,11 +334,30 @@ API
.. versionadded:: 1.16.0
+.. c:function:: unsigned int uv_available_parallelism(void)
+
+ Returns an estimate of the default amount of parallelism a program should
+ use. Always returns a non-zero value.
+
+ On Linux, inspects the calling thread's CPU affinity mask to determine if
+ it has been pinned to specific CPUs.
+
+ On Windows, the available parallelism may be underreported on systems with
+ more than 64 logical CPUs.
+
+ On other platforms, reports the number of CPUs that the operating system
+ considers to be online.
+
+ .. versionadded:: 1.44.0
+
.. c:function:: int uv_cpu_info(uv_cpu_info_t** cpu_infos, int* count)
Gets information about the CPUs on the system. The `cpu_infos` array will
have `count` elements and needs to be freed with :c:func:`uv_free_cpu_info`.
+ Use :c:func:`uv_available_parallelism` if you need to know how many CPUs
+ are available for threads or child processes.
+
.. c:function:: void uv_free_cpu_info(uv_cpu_info_t* cpu_infos, int count)
Frees the `cpu_infos` array previously allocated with :c:func:`uv_cpu_info`.