forked from qt-creator/qt-creator
TaskTree: Use QMutex consistently
There is no noticeable difference between using QMutex vs std::mutex in release build. It looks like std::mutex is about 15% faster than QMutex in debug build, but that's not relevant. Get rid of #include <atomic>. Change-Id: Iae67d5028c5ae3cb412e50d629bfc09b38417dfc Reviewed-by: <github-actions-qt-creator@cristianadam.eu> Reviewed-by: hjk <hjk@qt.io>
This commit is contained in:
@@ -13,8 +13,6 @@
|
||||
#include <QSet>
|
||||
#include <QTimer>
|
||||
|
||||
#include <atomic>
|
||||
|
||||
using namespace std::chrono;
|
||||
|
||||
namespace Tasking {
|
||||
@@ -1244,14 +1242,14 @@ class LoopData
|
||||
{
|
||||
public:
|
||||
LoopThreadData &threadData() {
|
||||
const std::lock_guard lock(m_threadDataMutex);
|
||||
QMutexLocker lock(&m_threadDataMutex);
|
||||
return m_threadDataMap.try_emplace(QThread::currentThread()).first->second;
|
||||
}
|
||||
|
||||
const std::optional<int> m_loopCount = {};
|
||||
const Loop::ValueGetter m_valueGetter = {};
|
||||
const Loop::Condition m_condition = {};
|
||||
std::mutex m_threadDataMutex = {};
|
||||
QMutex m_threadDataMutex = {};
|
||||
// Use std::map on purpose, so that it doesn't invalidate references on modifications.
|
||||
// Don't optimize it by using std::unordered_map.
|
||||
std::map<QThread *, LoopThreadData> m_threadDataMap = {};
|
||||
|
Reference in New Issue
Block a user