diff options
author | MÃ¥rten Nordheim <marten.nordheim@qt.io> | 2023-02-23 15:15:46 +0100 |
---|---|---|
committer | Qt Cherry-pick Bot <cherrypick_bot@qt-project.org> | 2023-02-28 16:20:46 +0000 |
commit | 655fdae1235476b43fb9d5bd43d12853ed7008c5 (patch) | |
tree | cfd43fd96ef91b3ffe5c4508a99f878e66a37682 /src/concurrent/qtconcurrentthreadengine.cpp | |
parent | 7f2efb1d9c5464a30d5ec99545eeaec635eb2cea (diff) | |
download | qtbase-655fdae1235476b43fb9d5bd43d12853ed7008c5.tar.gz |
QtConcurrent: yield CPU when spinning on atomics
Change-Id: I3eef19d8737da60bee40385a64a1bc136d2e7329
Reviewed-by: Thiago Macieira <thiago.macieira@intel.com>
(cherry picked from commit ee1651efdd32dfb96443828ddaeddccb3e4e3648)
Reviewed-by: Qt Cherry-pick Bot <cherrypick_bot@qt-project.org>
Diffstat (limited to 'src/concurrent/qtconcurrentthreadengine.cpp')
-rw-r--r-- | src/concurrent/qtconcurrentthreadengine.cpp | 6 |
1 files changed, 6 insertions, 0 deletions
diff --git a/src/concurrent/qtconcurrentthreadengine.cpp b/src/concurrent/qtconcurrentthreadengine.cpp index d10cca5de7..03e018b0a2 100644 --- a/src/concurrent/qtconcurrentthreadengine.cpp +++ b/src/concurrent/qtconcurrentthreadengine.cpp @@ -3,6 +3,8 @@ #include "qtconcurrentthreadengine.h" +#include <QtCore/private/qsimd_p.h> + #if !defined(QT_NO_CONCURRENT) || defined(Q_QDOC) QT_BEGIN_NAMESPACE @@ -63,6 +65,7 @@ void ThreadEngineBarrier::acquire() if (count.testAndSetOrdered(localCount, localCount + 1)) return; } + qYieldCpu(); } } @@ -82,6 +85,7 @@ int ThreadEngineBarrier::release() if (count.testAndSetOrdered(localCount, localCount - 1)) return localCount - 1; } + qYieldCpu(); } } @@ -98,6 +102,7 @@ void ThreadEngineBarrier::wait() semaphore.acquire(); return; } + qYieldCpu(); } } @@ -121,6 +126,7 @@ bool ThreadEngineBarrier::releaseUnlessLast() if (count.testAndSetOrdered(localCount, localCount - 1)) return true; } + qYieldCpu(); } } |