![]() |
Qt 6.x
The Qt SDK
|
\inmodule QtCore More...
#include <qmutex.h>
Additional Inherited Members | |
![]() | |
constexpr | QMutex () noexcept |
Constructs a new mutex. | |
void | lock () noexcept |
Locks the mutex. | |
bool | tryLock (int timeout=0) noexcept |
Attempts to lock the mutex. | |
bool | try_lock () noexcept |
void | unlock () noexcept |
Unlocks the mutex. | |
template<class Rep , class Period > | |
bool | try_lock_for (std::chrono::duration< Rep, Period > duration) noexcept |
template<class Clock , class Duration > | |
bool | try_lock_until (std::chrono::time_point< Clock, Duration > timePoint) noexcept |
\inmodule QtCore
The QRecursiveMutex class provides access serialization between threads.
\threadsafe
The QRecursiveMutex class is a mutex, like QMutex, with which it is API-compatible. It differs from QMutex by accepting lock() calls from the same thread any number of times. QMutex would deadlock in this situation.
QRecursiveMutex is much more expensive to construct and operate on, so use a plain QMutex whenever you can. Sometimes, one public function, however, calls another public function, and they both need to lock the same mutex. In this case, you have two options:
\list