QtConcurrent: yield CPU when spinning on atomics

Pick-to: 6.5
Change-Id: I3eef19d8737da60bee40385a64a1bc136d2e7329
Reviewed-by: Thiago Macieira <thiago.macieira@intel.com>
This commit is contained in:
Mårten Nordheim 2023-02-23 15:15:46 +01:00
parent 97dcf1ba18
commit ee1651efdd

View File

@ -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();
}
}