summaryrefslogtreecommitdiffstats
path: root/src/corelib/thread/qmutex.h
diff options
context:
space:
mode:
authorGiuseppe D'Angelo <giuseppe.dangelo@kdab.com>2022-03-06 14:29:54 +0100
committerGiuseppe D'Angelo <giuseppe.dangelo@kdab.com>2022-03-09 21:37:10 +0100
commitf875ff5180345d9e50d594f3f432d5c73eef30e4 (patch)
tree63bedd049d366af7e9971ab21b97a9d0c24aca0b /src/corelib/thread/qmutex.h
parent77e4177d1634ed8e1d7eed32bdd8e9967ae6e2fe (diff)
QMutexLocker: code tidies
Rename isLocked in preparation for a future commit. Rename m as well for consistency. Change-Id: I1c8d040bca6825a698ec804ea142d208abacd5cc Reviewed-by: Thiago Macieira <thiago.macieira@intel.com>
Diffstat (limited to 'src/corelib/thread/qmutex.h')
-rw-r--r--src/corelib/thread/qmutex.h28
1 files changed, 15 insertions, 13 deletions
diff --git a/src/corelib/thread/qmutex.h b/src/corelib/thread/qmutex.h
index 19463da619..fea3657150 100644
--- a/src/corelib/thread/qmutex.h
+++ b/src/corelib/thread/qmutex.h
@@ -240,43 +240,45 @@ class [[nodiscard]] QMutexLocker
public:
inline explicit QMutexLocker(Mutex *mutex) QT_MUTEX_LOCK_NOEXCEPT
{
- m = mutex;
+ m_mutex = mutex;
if (Q_LIKELY(mutex)) {
mutex->lock();
- isLocked = true;
+ m_isLocked = true;
}
}
- inline ~QMutexLocker() {
+
+ inline ~QMutexLocker()
+ {
unlock();
}
inline void unlock() noexcept
{
- if (!isLocked)
+ if (!m_isLocked)
return;
- m->unlock();
- isLocked = false;
+ m_mutex->unlock();
+ m_isLocked = false;
}
inline void relock() QT_MUTEX_LOCK_NOEXCEPT
{
- if (isLocked)
+ if (m_isLocked)
return;
- if (m) {
- m->lock();
- isLocked = true;
+ if (m_mutex) {
+ m_mutex->lock();
+ m_isLocked = true;
}
}
Mutex *mutex() const
{
- return m;
+ return m_mutex;
}
private:
Q_DISABLE_COPY(QMutexLocker)
- Mutex *m;
- bool isLocked = false;
+ Mutex *m_mutex;
+ bool m_isLocked = false;
};
#else // !QT_CONFIG(thread) && !Q_CLANG_QDOC