Locks
ReadersWriterLock
¶
A readers-writer lock (RW lock) implementation.
This lock allows multiple readers to hold the lock simultaneously, as long as there are no writers. When a writer requests the lock, it blocks until all current readers have released it. While a writer holds the lock, no other readers or writers can acquire it.
This implementation is reentrant: a reader or writer thread that already holds the lock can acquire it again, but every acquisition must be matched by a release.
It is recommended to use a with statement to manage the lock.
Example usage
Warning
Readers may not become writers and vice versa. That is, the following code will block forever:
Classes:
-
ReaderLock–A lock object that provides shared access for readers.
-
WriterLock–A lock object that provides exclusive access for writers.
Methods:
ReaderLock
¶
ReaderLock(rw_lock: ReadersWriterLock)
A lock object that provides shared access for readers.
Methods:
WriterLock
¶
WriterLock(rw_lock: ReadersWriterLock)
A lock object that provides exclusive access for writers.
Methods: