The QRecursiveMutexLocker class simplifies locking and unlocking mutexes. Locking and unlocking a QRecursiveMutex manually in complex functions or in exception handling code is error prone and can be difficult to debug. QRecursiveMutexLocker can be used in such situations to ensure the state of the mutex is always well defined.
The mutex will be locked when QRecursiveMutexLocker is created. You can unlock and relock the mutex with unlock() and relock(). If locked, the mutex will be unlocked when the QRecursiveMutexLocker is destroyed.
The QMutexLocker class provides the equivalent functionality for code which does not use a recursive mutex.
- See also
- QMutex, QMutexLocker, QReadLocker, QRecursiveMutex, QWriteLocker