summaryrefslogtreecommitdiffstats
path: root/src/corelib/thread/qmutex.h
diff options
context:
space:
mode:
authorLars Knoll <lars.knoll@qt.io>2020-09-10 09:54:51 +0200
committerLars Knoll <lars.knoll@qt.io>2020-10-17 12:03:16 +0200
commit3f477c7f0c163bcddd5fa8abf4f619dae315ebee (patch)
treee0377774389e5e1a3767b480e8b38685f20947a3 /src/corelib/thread/qmutex.h
parentf01ec0713d994ca25b226fab5163c849e288fe87 (diff)
Inline the members for QRecursiveMutex
Avoid creating a a d pointer for recursive mutexes. Change-Id: I28af15a416ee17de346e2ea5b1442279d9d3e159 Reviewed-by: Thiago Macieira <thiago.macieira@intel.com>
Diffstat (limited to 'src/corelib/thread/qmutex.h')
-rw-r--r--src/corelib/thread/qmutex.h15
1 files changed, 10 insertions, 5 deletions
diff --git a/src/corelib/thread/qmutex.h b/src/corelib/thread/qmutex.h
index 7800c14ff86..5f3b6d1b712 100644
--- a/src/corelib/thread/qmutex.h
+++ b/src/corelib/thread/qmutex.h
@@ -191,19 +191,24 @@ public:
}
};
-class QRecursiveMutexPrivate;
class Q_CORE_EXPORT QRecursiveMutex
{
Q_DISABLE_COPY_MOVE(QRecursiveMutex)
- QRecursiveMutexPrivate *d;
-public:
+ // written to by the thread that first owns 'mutex';
+ // read during attempts to acquire ownership of 'mutex' from any other thread:
+ QAtomicPointer<void> owner = nullptr;
+ // only ever accessed from the thread that owns 'mutex':
+ uint count = 0;
+ QMutex mutex;
- QRecursiveMutex();
+public:
+ constexpr QRecursiveMutex() = default;
~QRecursiveMutex();
// BasicLockable concept
- void lock() QT_MUTEX_LOCK_NOEXCEPT;
+ void lock() QT_MUTEX_LOCK_NOEXCEPT
+ { tryLock(-1); }
bool tryLock(int timeout = 0) QT_MUTEX_LOCK_NOEXCEPT;
// BasicLockable concept
void unlock() noexcept;