From c3fd08e42c7aa4e3b1722bcc1180f1e7f94edc7b Mon Sep 17 00:00:00 2001 From: Thiago Macieira Date: Wed, 16 Oct 2024 17:40:58 -0700 Subject: [PATCH] QThread: use load/store operations with explicit ordering MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit The implicit load is an acquire, which isn't necessary in any of these cases, including the two liens changing the store: they were creating a temporary QAtomicPointer, which introduced the loadAcquire(). I've left the qCDebug() lines alone. Pick-to: 6.5 Change-Id: If45e068eaaf3cd4d2c81fffd1459a779b4eb4110 Reviewed-by: MÃ¥rten Nordheim (cherry picked from commit 6806391600b5398d4fdb3c4d2d5e442289522756) Reviewed-by: Qt Cherry-pick Bot --- src/corelib/thread/qthread_unix.cpp | 2 +- src/corelib/thread/qthread_win.cpp | 4 ++-- 2 files changed, 3 insertions(+), 3 deletions(-) diff --git a/src/corelib/thread/qthread_unix.cpp b/src/corelib/thread/qthread_unix.cpp index 88d24b6493f..647b64775a4 100644 --- a/src/corelib/thread/qthread_unix.cpp +++ b/src/corelib/thread/qthread_unix.cpp @@ -178,7 +178,7 @@ QThreadData *QThreadData::current(bool createIfNecessary) data = new QThreadData; QT_TRY { set_thread_data(data); - data->thread = new QAdoptedThread(data); + data->thread.storeRelease(new QAdoptedThread(data)); } QT_CATCH(...) { clear_thread_data(); data->deref(); diff --git a/src/corelib/thread/qthread_win.cpp b/src/corelib/thread/qthread_win.cpp index 0fba38d250b..1c5b5bf965a 100644 --- a/src/corelib/thread/qthread_win.cpp +++ b/src/corelib/thread/qthread_win.cpp @@ -76,7 +76,7 @@ QThreadData *QThreadData::current(bool createIfNecessary) // avoid recursion. TlsSetValue(qt_current_thread_data_tls_index, threadData); QT_TRY { - threadData->thread = new QAdoptedThread(threadData); + threadData->thread.storeRelease(new QAdoptedThread(threadData)); } QT_CATCH(...) { TlsSetValue(qt_current_thread_data_tls_index, 0); threadData->deref(); @@ -101,7 +101,7 @@ QThreadData *QThreadData::current(bool createIfNecessary) 0, FALSE, DUPLICATE_SAME_ACCESS); - qt_watch_adopted_thread(realHandle, threadData->thread); + qt_watch_adopted_thread(realHandle, threadData->thread.loadRelaxed()); } } return threadData;