From e826e3ad7e412796735b98bb6d07c5e51a68181b Mon Sep 17 00:00:00 2001 From: Jarek Kobus Date: Tue, 2 Jan 2024 19:06:41 +0100 Subject: [PATCH] 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 . Change-Id: Iae67d5028c5ae3cb412e50d629bfc09b38417dfc Reviewed-by: Reviewed-by: hjk --- src/libs/solutions/tasking/tasktree.cpp | 6 ++---- 1 file changed, 2 insertions(+), 4 deletions(-) diff --git a/src/libs/solutions/tasking/tasktree.cpp b/src/libs/solutions/tasking/tasktree.cpp index 31d90bbfa9e..7b1162116fe 100644 --- a/src/libs/solutions/tasking/tasktree.cpp +++ b/src/libs/solutions/tasking/tasktree.cpp @@ -13,8 +13,6 @@ #include #include -#include - 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 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 m_threadDataMap = {};