QReadWriteLock: inline the lockForXxx functions
We can now do that because tryLockForXxxx(-1) is fast for the uncontended case too. Change-Id: I3d728c4197df49169066fffd1756ddd06caf7b52 Reviewed-by: Mårten Nordheim <marten.nordheim@qt.io>
This commit is contained in:
parent
34914099a1
commit
fcae43237b
@ -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
|
||||
|
@ -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<QReadWriteLock
|
||||
}
|
||||
|
||||
/*!
|
||||
\fn QReadWriteLock::lockForWrite()
|
||||
Locks the lock for writing. This function will block the current
|
||||
thread if another thread (including the current) has locked for
|
||||
reading or writing (unless the lock has been created using the
|
||||
@ -239,10 +237,6 @@ Q_NEVER_INLINE static bool contendedTryLockForRead(QAtomicPointer<QReadWriteLock
|
||||
|
||||
\sa unlock(), lockForRead(), tryLockForWrite()
|
||||
*/
|
||||
void QReadWriteLock::lockForWrite()
|
||||
{
|
||||
tryLockForWrite(-1);
|
||||
}
|
||||
|
||||
/*!
|
||||
Attempts to lock for writing. This function returns \c true if the
|
||||
|
@ -21,12 +21,14 @@ public:
|
||||
explicit QReadWriteLock(RecursionMode recursionMode = NonRecursive);
|
||||
~QReadWriteLock();
|
||||
|
||||
QT_CORE_INLINE_SINCE(6, 6)
|
||||
void lockForRead();
|
||||
#if QT_CORE_REMOVED_SINCE(6, 6)
|
||||
bool tryLockForRead();
|
||||
#endif
|
||||
bool tryLockForRead(int timeout = 0);
|
||||
|
||||
QT_CORE_INLINE_SINCE(6, 6)
|
||||
void lockForWrite();
|
||||
#if QT_CORE_REMOVED_SINCE(6, 6)
|
||||
bool tryLockForWrite();
|
||||
@ -41,6 +43,18 @@ private:
|
||||
friend class QReadWriteLockPrivate;
|
||||
};
|
||||
|
||||
#if QT_CORE_INLINE_IMPL_SINCE(6, 6)
|
||||
void QReadWriteLock::lockForRead()
|
||||
{
|
||||
tryLockForRead(-1);
|
||||
}
|
||||
|
||||
void QReadWriteLock::lockForWrite()
|
||||
{
|
||||
tryLockForWrite(-1);
|
||||
}
|
||||
#endif // inline since 6.6
|
||||
|
||||
#if defined(Q_CC_MSVC)
|
||||
#pragma warning( push )
|
||||
#pragma warning( disable : 4312 ) // ignoring the warning from /Wp64
|
||||
|
Loading…
Reference in New Issue
Block a user