From 30c117f129bf8f31b8c65cefe665fc0ef0969f42 Mon Sep 17 00:00:00 2001 From: Rasmus Karlsson Date: Wed, 6 Jun 2018 01:28:42 +0200 Subject: [PATCH] Add a mutable each function --- src/util/concurrentmap.hpp | 12 ++++++++++++ 1 file changed, 12 insertions(+) diff --git a/src/util/concurrentmap.hpp b/src/util/concurrentmap.hpp index 41b0ece3..d0602351 100644 --- a/src/util/concurrentmap.hpp +++ b/src/util/concurrentmap.hpp @@ -78,6 +78,18 @@ public: } } + void each(std::function func) + { + QMutexLocker lock(&this->mutex); + + QMutableMapIterator it(this->data); + + while (it.hasNext()) { + it.next(); + func(it.key(), it.value()); + } + } + private: mutable QMutex mutex; QMap data;