mirror of
https://github.com/Chatterino/chatterino2.git
synced 2024-11-21 22:24:07 +01:00
fixed concurrentmap
This commit is contained in:
parent
a29f76dce2
commit
15047946f4
1 changed files with 5 additions and 5 deletions
|
@ -32,21 +32,21 @@ public:
|
|||
return true;
|
||||
}
|
||||
|
||||
void
|
||||
getOrAdd(const TKey &name, TValue &value, std::function<TValue()> addLambda)
|
||||
TValue
|
||||
getOrAdd(const TKey &name, std::function<TValue()> 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
|
||||
|
|
Loading…
Reference in a new issue