QLogging: add qYieldCpu() to CAS loop

CAS failures should result in PAUSE/YIELD, cf. qYieldCpu() docs.

qYieldCpu() is only available since Qt 6.3, though, so adding it as a
follow-up with limited pick-to.

Task-number: QTBUG-115062
Change-Id: Ibcc73881875a47935940015e30b9a27a282054d4
Reviewed-by: Thiago Macieira <thiago.macieira@intel.com>
(cherry picked from commit 06d520dbef21f5debe9f092c63d2aa9b02afb4c3)
Reviewed-by: Qt Cherry-pick Bot <cherrypick_bot@qt-project.org>
This commit is contained in:
Marc Mutz 2023-07-05 08:54:34 +02:00 committed by Qt Cherry-pick Bot
parent c9fe146401
commit 0188af38b1

View File

@ -14,6 +14,7 @@
#include "qdebug.h"
#include "qmutex.h"
#include <QtCore/private/qlocking_p.h>
#include <QtCore/private/qsimd_p.h>
#include "qloggingcategory.h"
#ifndef QT_BOOTSTRAPPED
#include "qelapsedtimer.h"
@ -23,7 +24,6 @@
#include "qthread.h"
#include "private/qloggingregistry_p.h"
#include "private/qcoreapplication_p.h"
#include "private/qsimd_p.h"
#include <qtcore_tracepoints_p.h>
#endif
#ifdef Q_OS_WIN
@ -191,7 +191,7 @@ static bool is_fatal_count_down(QAtomicInt &n)
int v = n.loadRelaxed();
while (v != 0 && !n.testAndSetRelaxed(v, v - 1, v))
;
qYieldCpu();
return v == 1; // we exited the loop, so either v == 0 or CAS succeeded to set n from v to v-1
}