# HG changeset patch # Parent 1ea8b7233fd7556f68222e2a5c34736adb4ff26a diff --git a/Doc/library/threading.rst b/Doc/library/threading.rst --- a/Doc/library/threading.rst +++ b/Doc/library/threading.rst @@ -411,6 +411,9 @@ the state to unlocked; which one of the waiting threads proceeds is not defined, and may vary across implementations. +A primitive lock can be used as the context manager for a :keyword:`with` +statement (see :ref:`with-locks`). + All methods are executed atomically. @@ -475,6 +478,9 @@ pair) resets the lock to unlocked and allows another thread blocked in :meth:`acquire` to proceed. +A reentrant lock can be used as the context manager for a :keyword:`with` +statement (see :ref:`with-locks`). + .. method:: RLock.acquire(blocking=True, timeout=-1) @@ -534,6 +540,9 @@ be called when the calling thread has acquired the lock, otherwise a :exc:`RuntimeError` is raised. +A condition variable can be used as the context manager for a :keyword:`with` +statement (see :ref:`with-locks`). + The :meth:`wait` method releases the lock, and then blocks until it is awakened by a :meth:`notify` or :meth:`notify_all` call for the same condition variable in another thread. Once awakened, it re-acquires the lock and returns. It is also @@ -696,6 +705,9 @@ can never go below zero; when :meth:`acquire` finds that it is zero, it blocks, waiting until some other thread calls :meth:`release`. +A semaphore can be used as the context manager for a :keyword:`with` statement +(see :ref:`with-locks`). + .. class:: Semaphore(value=1)