42 #include "qplatformdefs.h" 158 if (d->
owner ==
self) {
160 Q_ASSERT_X(d->
count != 0,
"QMutex::lock",
"Overflow in recursion counter");
167 isLocked = d->
wait();
169 "Internal error, infinite wait has timed out.");
174 Q_ASSERT_X(d->
count != 0,
"QMutex::lock",
"Overflow in recursion counter");
208 if (d->
owner ==
self) {
210 Q_ASSERT_X(d->
count != 0,
"QMutex::tryLock",
"Overflow in recursion counter");
223 Q_ASSERT_X(d->
count != 0,
"QMutex::tryLock",
"Overflow in recursion counter");
263 if (d->
owner ==
self) {
265 Q_ASSERT_X(d->
count != 0,
"QMutex::tryLock",
"Overflow in recursion counter");
272 isLocked = d->
wait(timeout);
279 Q_ASSERT_X(d->
count != 0,
"QMutex::tryLock",
"Overflow in recursion counter");
285 || d->
wait(timeout));
460 bool isLocked = d->
wait();
462 "Internal error, infinite wait has timed out.");
468 elapsedTimer.
start();
473 elapsedTimer.
start();
474 bool isLocked = d->
wait();
476 "Internal error, infinite wait has timed out.");
504 if (spinTime < maximumSpinTime / 2) {
539 #endif // QT_NO_THREAD
Q_DECL_CONSTEXPR const T & qMin(const T &a, const T &b)
#define QT_END_NAMESPACE
This macro expands to.
void lock()
Locks the mutex.
bool testAndSetAcquire(int expectedValue, int newValue)
Atomic test-and-set.
bool wait(int timeout=-1)
volatile qint64 maximumSpinTime
The QElapsedTimer class provides a fast way to calculate elapsed times.
bool testAndSetRelease(int expectedValue, int newValue)
Atomic test-and-set.
static void yieldCurrentThread()
Yields execution of the current thread to another runnable thread, if any.
~QMutex()
Destroys the mutex.
#define QT_BEGIN_NAMESPACE
This macro expands to.
qint64 nsecsElapsed() const
Returns the number of nanoseconds since this QElapsedTimer was last started.
void unlock()
Unlocks the mutex.
#define Q_ASSERT_X(cond, where, what)
Q_DECL_CONSTEXPR const T & qBound(const T &min, const T &val, const T &max)
volatile qint64 averageWaitTime
bool tryLock()
Attempts to lock the mutex.
QMutex(RecursionMode mode=NonRecursive)
Constructs a new mutex.
#define Q_UNUSED(x)
Indicates to the compiler that the parameter with the specified name is not used in the body of a fun...
void start()
Starts this timer.
static Qt::HANDLE currentThreadId()
Returns the thread handle of the currently executing thread.
static int idealThreadCount()
Returns the ideal number of threads that can be run on the system.