aboutsummaryrefslogtreecommitdiff
path: root/docs/src
diff options
context:
space:
mode:
Diffstat (limited to 'docs/src')
-rw-r--r--docs/src/misc.rst7
-rw-r--r--docs/src/threading.rst31
2 files changed, 38 insertions, 0 deletions
diff --git a/docs/src/misc.rst b/docs/src/misc.rst
index f6d26efc..423ef84c 100644
--- a/docs/src/misc.rst
+++ b/docs/src/misc.rst
@@ -365,6 +365,13 @@ API
Frees the `cpu_infos` array previously allocated with :c:func:`uv_cpu_info`.
+.. c:function:: int uv_cpumask_size(void)
+
+ Returns the maximum size of the mask used for process/thread affinities,
+ or ``UV_ENOTSUP`` if affinities are not supported on the current platform.
+
+ .. versionadded:: 1.45.0
+
.. c:function:: int uv_interface_addresses(uv_interface_address_t** addresses, int* count)
Gets address information about the network interfaces on the system. An
diff --git a/docs/src/threading.rst b/docs/src/threading.rst
index 7ca1d4b7..ca9fb0ce 100644
--- a/docs/src/threading.rst
+++ b/docs/src/threading.rst
@@ -88,6 +88,37 @@ Threads
.. versionadded:: 1.26.0
+.. c:function:: int uv_thread_setaffinity(uv_thread_t* tid, char* cpumask, char* oldmask, size_t mask_size)
+
+ Sets the specified thread's affinity to cpumask, which is specified in
+ bytes. Optionally returning the previous affinity setting in oldmask.
+ On Unix, uses :man:`pthread_getaffinity_np(3)` to get the affinity setting
+ and maps the cpu_set_t to bytes in oldmask. Then maps the bytes in cpumask
+ to a cpu_set_t and uses :man:`pthread_setaffinity_np(3)`. On Windows, maps
+ the bytes in cpumask to a bitmask and uses SetThreadAffinityMask() which
+ returns the previous affinity setting.
+
+ The mask_size specifies the number of entries (bytes) in cpumask / oldmask,
+ and must be greater-than-or-equal-to :c:func:`uv_cpumask_size`.
+
+ .. note::
+ Thread affinity setting is not atomic on Windows. Unsupported on macOS.
+
+ .. versionadded:: 1.45.0
+
+.. c:function:: int uv_thread_getaffinity(uv_thread_t* tid, char* cpumask, size_t mask_size)
+
+ Gets the specified thread's affinity setting. On Unix, this maps the
+ cpu_set_t returned by :man:`pthread_getaffinity_np(3)` to bytes in cpumask.
+
+ The mask_size specifies the number of entries (bytes) in cpumask,
+ and must be greater-than-or-equal-to :c:func:`uv_cpumask_size`.
+
+ .. note::
+ Thread affinity getting is not atomic on Windows. Unsupported on macOS.
+
+ .. versionadded:: 1.45.0
+
.. c:function:: uv_thread_t uv_thread_self(void)
.. c:function:: int uv_thread_join(uv_thread_t *tid)
.. c:function:: int uv_thread_equal(const uv_thread_t* t1, const uv_thread_t* t2)