aboutsummaryrefslogtreecommitdiff
path: root/docs/src
diff options
context:
space:
mode:
authorScott Parker <scott.parker087@gmail.com>2017-09-21 10:36:20 -0700
committercjihrig <cjihrig@gmail.com>2017-10-02 10:01:09 -0400
commitec96b5543823c6ab5b6654a07c318b659e841563 (patch)
treeec25b0a698d47c2349e7cee64bbc4dcccd8f07e4 /docs/src
parent5b6eead0649bd3dae8e9636ba7cc04e024bba54c (diff)
downloadlibuv-ec96b5543823c6ab5b6654a07c318b659e841563.tar.gz
libuv-ec96b5543823c6ab5b6654a07c318b659e841563.zip
unix,win: add uv_mutex_init_recursive()
Support the creation of recursive mutexes on Unix. A matching API is added on Windows, however mutexes on Windows are always recursive. Refs: https://github.com/libuv/libuv/issues/1022 PR-URL: https://github.com/libuv/libuv/pull/1555 Reviewed-By: Ben Noordhuis <info@bnoordhuis.nl> Reviewed-By: Colin Ihrig <cjihrig@gmail.com>
Diffstat (limited to 'docs/src')
-rw-r--r--docs/src/guide/threads.rst14
-rw-r--r--docs/src/threading.rst1
2 files changed, 9 insertions, 6 deletions
diff --git a/docs/src/guide/threads.rst b/docs/src/guide/threads.rst
index 3b0a07e1..b6a4fd85 100644
--- a/docs/src/guide/threads.rst
+++ b/docs/src/guide/threads.rst
@@ -79,18 +79,21 @@ The mutex functions are a **direct** map to the pthread equivalents.
.. literalinclude:: ../../../include/uv.h
:lines: 1355-1360
-The ``uv_mutex_init()`` and ``uv_mutex_trylock()`` functions will return 0 on
-success, and an error code otherwise.
+The ``uv_mutex_init()``, ``uv_mutex_init_recursive()`` and ``uv_mutex_trylock()``
+functions will return 0 on success, and an error code otherwise.
If `libuv` has been compiled with debugging enabled, ``uv_mutex_destroy()``,
``uv_mutex_lock()`` and ``uv_mutex_unlock()`` will ``abort()`` on error.
Similarly ``uv_mutex_trylock()`` will abort if the error is anything *other
than* ``EAGAIN`` or ``EBUSY``.
-Recursive mutexes are supported by some platforms, but you should not rely on
-them. The BSD mutex implementation will raise an error if a thread which has
+Recursive mutexes are supported, but you should not rely on them. Also, they
+should not be used with ``uv_cond_t`` variables.
+
+The default BSD mutex implementation will raise an error if a thread which has
locked a mutex attempts to lock it again. For example, a construct like::
+ uv_mutex_init(a_mutex);
uv_mutex_lock(a_mutex);
uv_thread_create(thread_id, entry, (void *)a_mutex);
uv_mutex_lock(a_mutex);
@@ -102,8 +105,7 @@ return an error in the second call to ``uv_mutex_lock()``.
.. note::
- Mutexes on linux support attributes for a recursive mutex, but the API is
- not exposed via libuv.
+ Mutexes on Windows are always recursive.
Locks
~~~~~
diff --git a/docs/src/threading.rst b/docs/src/threading.rst
index e876dde1..bca8ba1d 100644
--- a/docs/src/threading.rst
+++ b/docs/src/threading.rst
@@ -91,6 +91,7 @@ Functions return 0 on success or an error code < 0 (unless the
return type is void, of course).
.. c:function:: int uv_mutex_init(uv_mutex_t* handle)
+.. c:function:: int uv_mutex_init_recursive(uv_mutex_t* handle)
.. c:function:: void uv_mutex_destroy(uv_mutex_t* handle)
.. c:function:: void uv_mutex_lock(uv_mutex_t* handle)
.. c:function:: int uv_mutex_trylock(uv_mutex_t* handle)