QReadWriteLock fast path for tryLock without timeout
When one tries to lock without a timeout, there is no need to allocate a QReadWriteLockPrivate as we will not wait on it. Change-Id: I37c96a7fbc0c66fbdffe372f6089708cb2466fe3 Reviewed-by: Edward Welbourne <edward.welbourne@qt.io> Reviewed-by: Thiago Macieira <thiago.macieira@intel.com>
This commit is contained in:
parent
a372cf5a80
commit
120ba68882
@ -244,6 +244,9 @@ bool QReadWriteLock::tryLockForRead(int timeout)
|
|||||||
}
|
}
|
||||||
|
|
||||||
if (d == dummyLockedForWrite) {
|
if (d == dummyLockedForWrite) {
|
||||||
|
if (!timeout)
|
||||||
|
return false;
|
||||||
|
|
||||||
// locked for write, assign a d_ptr and wait.
|
// locked for write, assign a d_ptr and wait.
|
||||||
auto val = QReadWriteLockPrivate::allocate();
|
auto val = QReadWriteLockPrivate::allocate();
|
||||||
val->writerCount = 1;
|
val->writerCount = 1;
|
||||||
@ -345,6 +348,9 @@ bool QReadWriteLock::tryLockForWrite(int timeout)
|
|||||||
}
|
}
|
||||||
|
|
||||||
if (isUncontendedLocked(d)) {
|
if (isUncontendedLocked(d)) {
|
||||||
|
if (!timeout)
|
||||||
|
return false;
|
||||||
|
|
||||||
// locked for either read or write, assign a d_ptr and wait.
|
// locked for either read or write, assign a d_ptr and wait.
|
||||||
auto val = QReadWriteLockPrivate::allocate();
|
auto val = QReadWriteLockPrivate::allocate();
|
||||||
if (d == dummyLockedForWrite)
|
if (d == dummyLockedForWrite)
|
||||||
|
Loading…
x
Reference in New Issue
Block a user