diff --git a/src/UserData/UserDataStorage.cpp b/src/UserData/UserDataStorage.cpp index 466ae94..73bc099 100644 --- a/src/UserData/UserDataStorage.cpp +++ b/src/UserData/UserDataStorage.cpp @@ -3,4 +3,5 @@ namespace Porygon::UserData { UserDataStorage::_internalDataStorage UserDataStorage::_internal = UserDataStorage::_internalDataStorage(); + std::mutex UserDataStorage::_userDataMutex = std::mutex(); } \ No newline at end of file diff --git a/src/UserData/UserDataStorage.hpp b/src/UserData/UserDataStorage.hpp index a206c0a..c7bd012 100644 --- a/src/UserData/UserDataStorage.hpp +++ b/src/UserData/UserDataStorage.hpp @@ -12,7 +12,6 @@ namespace Porygon::UserData { class _internalDataStorage { public: std::unordered_map _userData; - std::mutex _userDataMutex; ~_internalDataStorage(){ for (auto u: _userData){ @@ -28,15 +27,16 @@ namespace Porygon::UserData { }; static _internalDataStorage _internal; + static std::mutex _userDataMutex; public: static void RegisterType(uint32_t i, UserData *ud) { - std::lock_guard guard(_internal._userDataMutex); + std::lock_guard guard(_userDataMutex); UserDataStorage::_internal._userData.insert({i, ud}); } static void ClearTypes(){ - std::lock_guard guard(_internal._userDataMutex); + std::lock_guard guard(_userDataMutex); for (auto u: _internal._userData){ delete u.second; }