From 15047946f439dbf6138887d3eff6bfa312837b69 Mon Sep 17 00:00:00 2001 From: fourtf Date: Sun, 29 Jan 2017 16:18:06 +0100 Subject: [PATCH] fixed concurrentmap --- concurrentmap.h | 10 +++++----- 1 file changed, 5 insertions(+), 5 deletions(-) diff --git a/concurrentmap.h b/concurrentmap.h index e4068f925..36fdddd33 100644 --- a/concurrentmap.h +++ b/concurrentmap.h @@ -32,21 +32,21 @@ public: return true; } - void - getOrAdd(const TKey &name, TValue &value, std::function addLambda) + TValue + getOrAdd(const TKey &name, std::function addLambda) { this->mutex->lock(); auto a = map.find(name); if (a == map.end()) { - value = addLambda(); + TValue value = addLambda(); map.insert(name, value); this->mutex->unlock(); + return value; } - value = a.value(); - this->mutex->unlock(); + return a.value(); } void