From fda8a09766bf733ccf97743ea5b884c900f44c28 Mon Sep 17 00:00:00 2001 From: Giacomo Pozzoni Date: Sat, 18 Jul 2020 16:34:45 +0000 Subject: Core/Misc: Replace boost::shared_mutex with std::shared_mutex (#24328) * Core/Misc: Replace boost::shared_mutex with std::shared_mutex * Remove std forward declarations (cherry picked from commit 7032ee0bdb47c995dfd89bce3d5b6fad13ec6d73) --- src/server/shared/Realm/RealmList.cpp | 15 ++++++--------- src/server/shared/Realm/RealmList.h | 5 ++--- 2 files changed, 8 insertions(+), 12 deletions(-) (limited to 'src/server/shared') diff --git a/src/server/shared/Realm/RealmList.cpp b/src/server/shared/Realm/RealmList.cpp index 094982d001c..1f1cd6326f0 100644 --- a/src/server/shared/Realm/RealmList.cpp +++ b/src/server/shared/Realm/RealmList.cpp @@ -29,13 +29,10 @@ #include "game_utilities_service.pb.h" #include "RealmList.pb.h" #include -#include -#include #include RealmList::RealmList() : _updateInterval(0) { - _realmsMutex = std::make_unique(); } RealmList::~RealmList() = default; @@ -211,7 +208,7 @@ void RealmList::UpdateRealms(boost::system::error_code const& error) TC_LOG_INFO("realmlist", "Removed realm \"%s\".", itr->second.c_str()); { - std::unique_lock lock(*_realmsMutex); + std::unique_lock lock(_realmsMutex); _subRegions.swap(newSubRegions); _realms.swap(newRealms); @@ -226,7 +223,7 @@ void RealmList::UpdateRealms(boost::system::error_code const& error) Realm const* RealmList::GetRealm(Battlenet::RealmHandle const& id) const { - boost::shared_lock lock(*_realmsMutex); + std::shared_lock lock(_realmsMutex); auto itr = _realms.find(id); if (itr != _realms.end()) return &itr->second; @@ -254,7 +251,7 @@ uint32 RealmList::GetMinorMajorBugfixVersionForBuild(uint32 build) const void RealmList::WriteSubRegions(bgs::protocol::game_utilities::v1::GetAllValuesForAttributeResponse* response) const { - boost::shared_lock lock(*_realmsMutex); + std::shared_lock lock(_realmsMutex); for (std::string const& subRegion : _subRegions) response->add_attribute_value()->set_string_value(subRegion); } @@ -262,7 +259,7 @@ void RealmList::WriteSubRegions(bgs::protocol::game_utilities::v1::GetAllValuesF std::vector RealmList::GetRealmEntryJSON(Battlenet::RealmHandle const& id, uint32 build) const { std::vector compressed; - boost::shared_lock lock(*_realmsMutex); + std::shared_lock lock(_realmsMutex); if (Realm const* realm = GetRealm(id)) { if (!(realm->Flags & REALM_FLAG_OFFLINE) && realm->Build == build) @@ -317,7 +314,7 @@ std::vector RealmList::GetRealmList(uint32 build, std::string const& subR { JSON::RealmList::RealmListUpdates realmList; { - boost::shared_lock lock(*_realmsMutex); + std::shared_lock lock(_realmsMutex); for (auto const& realm : _realms) { if (realm.second.Id.GetSubRegionAddress() != subRegion) @@ -376,7 +373,7 @@ std::vector RealmList::GetRealmList(uint32 build, std::string const& subR uint32 RealmList::JoinRealm(uint32 realmAddress, uint32 build, boost::asio::ip::address const& clientAddress, std::array const& clientSecret, LocaleConstant locale, std::string const& os, std::string accountName, bgs::protocol::game_utilities::v1::ClientResponse* response) const { - boost::shared_lock lock(*_realmsMutex); + std::shared_lock lock(_realmsMutex); if (Realm const* realm = GetRealm(Battlenet::RealmHandle(realmAddress))) { if (realm->Flags & REALM_FLAG_OFFLINE || realm->Build != build) diff --git a/src/server/shared/Realm/RealmList.h b/src/server/shared/Realm/RealmList.h index bd7270e73a3..9bf64270589 100644 --- a/src/server/shared/Realm/RealmList.h +++ b/src/server/shared/Realm/RealmList.h @@ -22,6 +22,7 @@ #include "Realm.h" #include #include +#include #include #include @@ -38,8 +39,6 @@ struct RealmBuildInfo namespace boost { - class shared_mutex; - namespace system { class error_code; @@ -102,7 +101,7 @@ private: uint16 port, uint8 icon, RealmFlags flag, uint8 timezone, AccountTypes allowedSecurityLevel, float population); std::vector _builds; - std::unique_ptr _realmsMutex; + mutable std::shared_mutex _realmsMutex; RealmMap _realms; std::unordered_set _subRegions; uint32 _updateInterval; -- cgit v1.2.3