summaryrefslogtreecommitdiffstats
path: root/src
diff options
context:
space:
mode:
authorThiago Macieira <thiago.macieira@intel.com>2025-02-13 16:33:28 -0800
committerThiago Macieira <thiago.macieira@intel.com>2025-08-14 11:36:30 -0700
commit51bc150382ade63d91f150168a4c757d63510bc3 (patch)
tree5e4bd3935ce4d5013c13539a250b5a658ccaffd8 /src
parentacde39e10206c16fd8b98e1cdf995913d3b9867f (diff)
QMutex: mark the uncontended paths as Q_LIKELY
Change-Id: I72ae8d8975c26d1f2e81fffd5839a2500f5edcb6 Reviewed-by: Allan Sandfeld Jensen <allan.jensen@qt.io>
Diffstat (limited to 'src')
-rw-r--r--src/corelib/thread/qmutex.h4
1 files changed, 2 insertions, 2 deletions
diff --git a/src/corelib/thread/qmutex.h b/src/corelib/thread/qmutex.h
index 5753d9faafa..a92fdc79c56 100644
--- a/src/corelib/thread/qmutex.h
+++ b/src/corelib/thread/qmutex.h
@@ -55,7 +55,7 @@ public:
if constexpr (FutexAlwaysAvailable) {
// we always unlock if we have futexes
- if (QMutexPrivate *d = d_ptr.fetchAndStoreRelease(nullptr); d != dummyLocked())
+ if (QMutexPrivate *d = d_ptr.fetchAndStoreRelease(nullptr); Q_UNLIKELY(d != dummyLocked()))
unlockInternalFutex(d); // was contended
} else {
// if we don't have futexes, we can only unlock if not contended
@@ -85,7 +85,7 @@ public:
private:
inline bool fastTryLock() noexcept
{
- if (d_ptr.loadRelaxed() != nullptr)
+ if (Q_UNLIKELY(d_ptr.loadRelaxed() != nullptr))
return false;
return d_ptr.testAndSetAcquire(nullptr, dummyLocked());
}