Skip to content

Commit

Permalink
Implement thread safe HashMap::erase
Browse files Browse the repository at this point in the history
  • Loading branch information
cpgr committed Aug 29, 2019
1 parent b566e98 commit 167fd40
Showing 1 changed file with 7 additions and 1 deletion.
8 changes: 7 additions & 1 deletion framework/include/utils/HashMap.h
Expand Up @@ -25,9 +25,15 @@ class HashMap : public std::unordered_map<Key, T>
return std::unordered_map<Key, T>::operator[](k);
}

inline std::size_t erase(const Key & k)
{
libMesh::Threads::spin_mutex::scoped_lock lock(spin_mutex);

return std::unordered_map<Key, T>::erase(k);
}

inline bool contains(const Key & key) { return this->find(key) != this->end(); }

private:
libMesh::Threads::spin_mutex spin_mutex;
};

0 comments on commit 167fd40

Please sign in to comment.