diff options
| author | Marc Mutz <marc.mutz@qt.io> | 2022-05-17 17:19:54 +0200 |
|---|---|---|
| committer | Marc Mutz <marc.mutz@qt.io> | 2022-05-18 06:37:50 +0200 |
| commit | ae765813d082d403889d2f98a9c21bd9628cdd58 (patch) | |
| tree | b8fcf1735f1b4f652f6023b013767ac616ee4391 /src/corelib/kernel/qobject.cpp | |
| parent | adb4a3beb7a0e02d4e4f96dadaa6587298c4d1f5 (diff) | |
Optimize atomics in QObject::moveToThread() [2/2]: de-duplicate loads
We don't need to reload d->threadData, as we've already loaded it into
a register three lines above, so use the already-loaded value.
We don't care whether we might have read a different value the second
time around, because that would mean we had a race condition elsewhere
in the program (e.g. concurrent moveToThread() calls).
Pick-to: 6.3
Change-Id: I29a27ca23302288b5900ac6b45b8690a80e85680
Reviewed-by: Thiago Macieira <thiago.macieira@intel.com>
Reviewed-by: Qt CI Bot <qt_ci_bot@qt-project.org>
Diffstat (limited to 'src/corelib/kernel/qobject.cpp')
| -rw-r--r-- | src/corelib/kernel/qobject.cpp | 2 |
1 files changed, 1 insertions, 1 deletions
diff --git a/src/corelib/kernel/qobject.cpp b/src/corelib/kernel/qobject.cpp index 6dfa7c3e674..3254f2a9feb 100644 --- a/src/corelib/kernel/qobject.cpp +++ b/src/corelib/kernel/qobject.cpp @@ -1820,7 +1820,7 @@ void QObject::moveToThread(QThread *targetThread) QThreadData *thisThreadData = d->threadData.loadAcquire(); if (!thisThreadData->thread.loadRelaxed() && currentData == targetData) { // one exception to the rule: we allow moving objects with no thread affinity to the current thread - currentData = d->threadData; + currentData = thisThreadData; } else if (thisThreadData != currentData) { qWarning("QObject::moveToThread: Current thread (%p) is not the object's thread (%p).\n" "Cannot move to target thread (%p)\n", |
