ReadWriteLock
Base classes
| Name |
Children |
Inherits |
QReadWriteLock PySide6.QtCore QReadWriteLock(self, /, recursionMode: PySide6.QtCore.QReadWriteLock.RecursionMode \= Instance(PySide6.QtCore.QReadWriteLock.RecursionMode.NonRecursive)) -> None |
|
|
⋔ Inheritance diagram
graph TD
560916254["core.ReadWriteLock"]
2945360515["QtCore.QReadWriteLock"]
697148016["QtCore.QBasicReadWriteLock"]
37984305["Shiboken.Object"]
2751680898["builtins.object"]
2945360515 --> 560916254
697148016 --> 2945360515
37984305 --> 697148016
2751680898 --> 37984305
🛈 DocStrings
Bases: QReadWriteLock
Read-write locking between threads.
Source code in prettyqt/core/readwritelock.py
| class ReadWriteLock(QtCore.QReadWriteLock):
"""Read-write locking between threads."""
def __init__(
self,
recursion_mode: RecursionModeStr
| QtCore.QReadWriteLock.RecursionMode = "non_recursive",
):
super().__init__(RECURSION_MODE.get_enum_value(recursion_mode))
@contextlib.contextmanager
def lock_for_read(self, timeout: int | None = None) -> Generator[bool]:
acquired = (
self.tryLockForRead() if timeout is None else self.tryLockForRead(timeout)
)
try:
yield acquired
finally:
if acquired:
self.unlock()
@contextlib.contextmanager
def lock_for_write(self, timeout: int | None = None) -> Generator[bool]:
acquired = (
self.tryLockForWrite() if timeout is None else self.tryLockForWrite(timeout)
)
try:
yield acquired
finally:
if acquired:
self.unlock()
|
:fa-brands-github: Show source on GitHub