aboutsummaryrefslogtreecommitdiff
path: root/src/server/shared/Realm
diff options
context:
space:
mode:
authorGiacomo Pozzoni <giacomopoz@gmail.com>2020-07-18 16:34:45 +0000
committerShauren <shauren.trinity@gmail.com>2022-01-23 21:51:47 +0100
commitfda8a09766bf733ccf97743ea5b884c900f44c28 (patch)
tree5a28840356e9daca81ceaf11737c039cdd3d095e /src/server/shared/Realm
parent196a62c03184d696a3af8cc1c6e7993058ffe9c4 (diff)
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)
Diffstat (limited to 'src/server/shared/Realm')
-rw-r--r--src/server/shared/Realm/RealmList.cpp15
-rw-r--r--src/server/shared/Realm/RealmList.h5
2 files changed, 8 insertions, 12 deletions
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 <boost/asio/ip/tcp.hpp>
-#include <boost/thread/locks.hpp>
-#include <boost/thread/shared_mutex.hpp>
#include <zlib.h>
RealmList::RealmList() : _updateInterval(0)
{
- _realmsMutex = std::make_unique<boost::shared_mutex>();
}
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<boost::shared_mutex> lock(*_realmsMutex);
+ std::unique_lock<std::shared_mutex> 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<boost::shared_mutex> lock(*_realmsMutex);
+ std::shared_lock<std::shared_mutex> 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<boost::shared_mutex> lock(*_realmsMutex);
+ std::shared_lock<std::shared_mutex> 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<uint8> RealmList::GetRealmEntryJSON(Battlenet::RealmHandle const& id, uint32 build) const
{
std::vector<uint8> compressed;
- boost::shared_lock<boost::shared_mutex> lock(*_realmsMutex);
+ std::shared_lock<std::shared_mutex> lock(_realmsMutex);
if (Realm const* realm = GetRealm(id))
{
if (!(realm->Flags & REALM_FLAG_OFFLINE) && realm->Build == build)
@@ -317,7 +314,7 @@ std::vector<uint8> RealmList::GetRealmList(uint32 build, std::string const& subR
{
JSON::RealmList::RealmListUpdates realmList;
{
- boost::shared_lock<boost::shared_mutex> lock(*_realmsMutex);
+ std::shared_lock<std::shared_mutex> lock(_realmsMutex);
for (auto const& realm : _realms)
{
if (realm.second.Id.GetSubRegionAddress() != subRegion)
@@ -376,7 +373,7 @@ std::vector<uint8> RealmList::GetRealmList(uint32 build, std::string const& subR
uint32 RealmList::JoinRealm(uint32 realmAddress, uint32 build, boost::asio::ip::address const& clientAddress, std::array<uint8, 32> const& clientSecret,
LocaleConstant locale, std::string const& os, std::string accountName, bgs::protocol::game_utilities::v1::ClientResponse* response) const
{
- boost::shared_lock<boost::shared_mutex> lock(*_realmsMutex);
+ std::shared_lock<std::shared_mutex> 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 <array>
#include <map>
+#include <shared_mutex>
#include <vector>
#include <unordered_set>
@@ -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<RealmBuildInfo> _builds;
- std::unique_ptr<boost::shared_mutex> _realmsMutex;
+ mutable std::shared_mutex _realmsMutex;
RealmMap _realms;
std::unordered_set<std::string> _subRegions;
uint32 _updateInterval;