move mutex closer to guard call
continuous-integration/drone/push Build is failing
Details
continuous-integration/drone/push Build is failing
Details
Signed-off-by: Deukhoofd <deukhoofd@gmail.com>
This commit is contained in:
parent
e363d55206
commit
e13d75a502
|
@ -3,4 +3,5 @@
|
|||
|
||||
namespace Porygon::UserData {
|
||||
UserDataStorage::_internalDataStorage UserDataStorage::_internal = UserDataStorage::_internalDataStorage();
|
||||
std::mutex UserDataStorage::_userDataMutex = std::mutex();
|
||||
}
|
|
@ -12,7 +12,6 @@ namespace Porygon::UserData {
|
|||
class _internalDataStorage {
|
||||
public:
|
||||
std::unordered_map<uint32_t, UserData*> _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<std::mutex> guard(_internal._userDataMutex);
|
||||
std::lock_guard<std::mutex> guard(_userDataMutex);
|
||||
UserDataStorage::_internal._userData.insert({i, ud});
|
||||
}
|
||||
|
||||
static void ClearTypes(){
|
||||
std::lock_guard<std::mutex> guard(_internal._userDataMutex);
|
||||
std::lock_guard<std::mutex> guard(_userDataMutex);
|
||||
for (auto u: _internal._userData){
|
||||
delete u.second;
|
||||
}
|
||||
|
|
Loading…
Reference in New Issue