QReadWriteLock: remove the untimed tryLockForXxxx functions

They're unnecessary now because the timed function is fast enough.

Note: the default argument will move to the QDeadlineTimer functions
before the Qt 6.6 release.

Change-Id: I3d728c4197df49169066fffd1756ddc0e4f796d3
Reviewed-by: Mårten Nordheim <marten.nordheim@qt.io>
This commit is contained in:
Thiago Macieira 2023-04-17 16:48:51 -07:00
parent 834c755977
commit 34914099a1
3 changed files with 17 additions and 44 deletions

View File

@ -525,6 +525,17 @@ qsizetype QString::toUcs4_helper(const ushort *uc, qsizetype length, uint *out)
}
#if QT_CONFIG(thread)
#include "qreadwritelock.h"
bool QReadWriteLock::tryLockForRead()
{
return tryLockForRead(0);
}
bool QReadWriteLock::tryLockForWrite()
{
return tryLockForWrite(0);
}
#include "qthreadpool.h"
#include "private/qthreadpool_p.h"

View File

@ -146,27 +146,6 @@ void QReadWriteLock::lockForRead()
}
/*!
Attempts to lock for reading. If the lock was obtained, this
function returns \c true, otherwise it returns \c false instead of
waiting for the lock to become available, i.e. it does not block.
The lock attempt will fail if another thread has locked for
writing.
If the lock was obtained, the lock must be unlocked with unlock()
before another thread can successfully lock it for writing.
It is not possible to lock for read if the thread already has
locked for write.
\sa unlock(), lockForRead()
*/
bool QReadWriteLock::tryLockForRead()
{
return tryLockForRead(0);
}
/*! \overload
Attempts to lock for reading. This function returns \c true if the
lock was obtained; otherwise it returns \c false. If another thread
@ -266,27 +245,6 @@ void QReadWriteLock::lockForWrite()
}
/*!
Attempts to lock for writing. If the lock was obtained, this
function returns \c true; otherwise, it returns \c false immediately.
The lock attempt will fail if another thread has locked for
reading or writing.
If the lock was obtained, the lock must be unlocked with unlock()
before another thread can successfully lock it.
It is not possible to lock for write if the thread already has
locked for read.
\sa unlock(), lockForWrite()
*/
bool QReadWriteLock::tryLockForWrite()
{
return tryLockForWrite(0);
}
/*! \overload
Attempts to lock for writing. This function returns \c true if the
lock was obtained; otherwise it returns \c false. If another thread
has locked for reading or writing, this function will wait for at

View File

@ -22,12 +22,16 @@ public:
~QReadWriteLock();
void lockForRead();
#if QT_CORE_REMOVED_SINCE(6, 6)
bool tryLockForRead();
bool tryLockForRead(int timeout);
#endif
bool tryLockForRead(int timeout = 0);
void lockForWrite();
#if QT_CORE_REMOVED_SINCE(6, 6)
bool tryLockForWrite();
bool tryLockForWrite(int timeout);
#endif
bool tryLockForWrite(int timeout = 0);
void unlock();