qudi.util.mutex.Mutex
- class qudi.util.mutex.Mutex[source]
Bases:
PySide2.QtCore.QMutexExtends QMutex which serves as access serialization between threads.
This class provides: * Drop-in replacement for threading.Lock * Context management (enter/exit)
- __init__(*args, **kwargs)
Methods
__init__(*args, **kwargs)acquire([blocking, timeout])Mimics threading.Lock.acquire() to allow this class as a drop-in replacement.
isRecursive(self)lock(self)release()Mimics threading.Lock.release() to allow this class as a drop-in replacement.
tryLock(-> bool)try_lock(self)unlock(self)Attributes
- NonRecursive = PySide2.QtCore.QMutex.RecursionMode.NonRecursive
- class RecursionMode
Bases:
builtins.object- NonRecursive = PySide2.QtCore.QMutex.RecursionMode.NonRecursive
- Recursive = PySide2.QtCore.QMutex.RecursionMode.Recursive
- name
!! processed by numpydoc !!
- values = {'NonRecursive': PySide2.QtCore.QMutex.RecursionMode.NonRecursive, 'Recursive': PySide2.QtCore.QMutex.RecursionMode.Recursive}
- Recursive = PySide2.QtCore.QMutex.RecursionMode.Recursive
- __exit__(*args)[source]
Exit context.
- Parameters:
- *args
Context arguments (type, value, traceback) passed to the method.
- acquire(blocking: bool | None = True, timeout: int | float | None = -1) bool[source]
Mimics threading.Lock.acquire() to allow this class as a drop-in replacement.
- Parameters:
- blockingbool, optional
If True, this method will block until the mutex is locked (up to <timeout> seconds). If False, this method will return immediately regardless of the lock status. Default is True.
- timeoutfloat, optional
Timeout in seconds specifying the maximum wait time for the mutex to be able to lock. Negative numbers correspond to infinite wait time. This parameter is ignored if blocking is False. Default is -1.0.
- isRecursive(self) bool
- lock(self) None
- release() None[source]
Mimics threading.Lock.release() to allow this class as a drop-in replacement.
- tryLock(self) bool
- tryLock(self, timeout: int = 0) bool
- try_lock(self) bool
- unlock(self) None