From fcae43237b7501d9da1dc1b838bf4cdb28d3fd91 Mon Sep 17 00:00:00 2001 From: Thiago Macieira Date: Mon, 17 Apr 2023 16:49:58 -0700 Subject: [PATCH] QReadWriteLock: inline the lockForXxx functions MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit We can now do that because tryLockForXxxx(-1) is fast for the uncontended case too. Change-Id: I3d728c4197df49169066fffd1756ddd06caf7b52 Reviewed-by: MÃ¥rten Nordheim --- src/corelib/compat/removed_api.cpp | 4 ++++ src/corelib/thread/qreadwritelock.cpp | 10 ++-------- src/corelib/thread/qreadwritelock.h | 14 ++++++++++++++ 3 files changed, 20 insertions(+), 8 deletions(-) diff --git a/src/corelib/compat/removed_api.cpp b/src/corelib/compat/removed_api.cpp index b7c5ae84538..d810da59e82 100644 --- a/src/corelib/compat/removed_api.cpp +++ b/src/corelib/compat/removed_api.cpp @@ -601,6 +601,10 @@ QStringView QXmlStreamAttributes::value(QLatin1StringView qualifiedName) const return value(QAnyStringView(qualifiedName)); } +// inlined API +#if QT_CONFIG(thread) +#include "qreadwritelock.h" +#endif // #include "qotherheader.h" // // implement removed functions from qotherheader.h diff --git a/src/corelib/thread/qreadwritelock.cpp b/src/corelib/thread/qreadwritelock.cpp index 7e29aa3905c..36f051408e3 100644 --- a/src/corelib/thread/qreadwritelock.cpp +++ b/src/corelib/thread/qreadwritelock.cpp @@ -132,6 +132,7 @@ QReadWriteLock::~QReadWriteLock() } /*! + \fn QReadWriteLock::lockForRead() Locks the lock for reading. This function will block the current thread if another thread has locked for writing. @@ -140,10 +141,6 @@ QReadWriteLock::~QReadWriteLock() \sa unlock(), lockForWrite(), tryLockForRead() */ -void QReadWriteLock::lockForRead() -{ - tryLockForRead(-1); -} /*! @@ -229,6 +226,7 @@ Q_NEVER_INLINE static bool contendedTryLockForRead(QAtomicPointer