mirror of
https://github.com/TrinityCore/TrinityCore.git
synced 2026-01-16 15:40:45 +01:00
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
This commit is contained in:
@@ -30,9 +30,6 @@
|
||||
#include "Transport.h"
|
||||
#include "World.h"
|
||||
|
||||
#include <boost/thread/shared_mutex.hpp>
|
||||
#include <boost/thread/locks.hpp>
|
||||
|
||||
template<class T>
|
||||
void HashMapHolder<T>::Insert(T* o)
|
||||
{
|
||||
@@ -40,7 +37,7 @@ void HashMapHolder<T>::Insert(T* o)
|
||||
|| std::is_same<Transport, T>::value,
|
||||
"Only Player and Transport can be registered in global HashMapHolder");
|
||||
|
||||
boost::unique_lock<boost::shared_mutex> lock(*GetLock());
|
||||
std::unique_lock<std::shared_mutex> lock(*GetLock());
|
||||
|
||||
GetContainer()[o->GetGUID()] = o;
|
||||
}
|
||||
@@ -48,7 +45,7 @@ void HashMapHolder<T>::Insert(T* o)
|
||||
template<class T>
|
||||
void HashMapHolder<T>::Remove(T* o)
|
||||
{
|
||||
boost::unique_lock<boost::shared_mutex> lock(*GetLock());
|
||||
std::unique_lock<std::shared_mutex> lock(*GetLock());
|
||||
|
||||
GetContainer().erase(o->GetGUID());
|
||||
}
|
||||
@@ -56,7 +53,7 @@ void HashMapHolder<T>::Remove(T* o)
|
||||
template<class T>
|
||||
T* HashMapHolder<T>::Find(ObjectGuid guid)
|
||||
{
|
||||
boost::shared_lock<boost::shared_mutex> lock(*GetLock());
|
||||
std::shared_lock<std::shared_mutex> lock(*GetLock());
|
||||
|
||||
typename MapType::iterator itr = GetContainer().find(guid);
|
||||
return (itr != GetContainer().end()) ? itr->second : nullptr;
|
||||
@@ -70,9 +67,9 @@ auto HashMapHolder<T>::GetContainer() -> MapType&
|
||||
}
|
||||
|
||||
template<class T>
|
||||
boost::shared_mutex* HashMapHolder<T>::GetLock()
|
||||
std::shared_mutex* HashMapHolder<T>::GetLock()
|
||||
{
|
||||
static boost::shared_mutex _lock;
|
||||
static std::shared_mutex _lock;
|
||||
return &_lock;
|
||||
}
|
||||
|
||||
@@ -266,7 +263,7 @@ Player* ObjectAccessor::FindConnectedPlayerByName(std::string const& name)
|
||||
|
||||
void ObjectAccessor::SaveAllPlayers()
|
||||
{
|
||||
boost::shared_lock<boost::shared_mutex> lock(*HashMapHolder<Player>::GetLock());
|
||||
std::shared_lock<std::shared_mutex> lock(*HashMapHolder<Player>::GetLock());
|
||||
|
||||
HashMapHolder<Player>::MapType const& m = GetPlayers();
|
||||
for (HashMapHolder<Player>::MapType::const_iterator itr = m.begin(); itr != m.end(); ++itr)
|
||||
|
||||
@@ -19,6 +19,7 @@
|
||||
#define TRINITY_OBJECTACCESSOR_H
|
||||
|
||||
#include "ObjectGuid.h"
|
||||
#include <shared_mutex>
|
||||
#include <unordered_map>
|
||||
|
||||
class Corpse;
|
||||
@@ -33,11 +34,6 @@ class Transport;
|
||||
class Unit;
|
||||
class WorldObject;
|
||||
|
||||
namespace boost
|
||||
{
|
||||
class shared_mutex;
|
||||
}
|
||||
|
||||
template <class T>
|
||||
class TC_GAME_API HashMapHolder
|
||||
{
|
||||
@@ -56,7 +52,7 @@ public:
|
||||
|
||||
static MapType& GetContainer();
|
||||
|
||||
static boost::shared_mutex* GetLock();
|
||||
static std::shared_mutex* GetLock();
|
||||
};
|
||||
|
||||
namespace ObjectAccessor
|
||||
|
||||
@@ -25,9 +25,6 @@
|
||||
#include "ObjectMgr.h"
|
||||
#include "Player.h"
|
||||
|
||||
#include <boost/thread/shared_mutex.hpp>
|
||||
#include <boost/thread/locks.hpp>
|
||||
|
||||
#include <unordered_map>
|
||||
|
||||
namespace
|
||||
@@ -47,9 +44,9 @@ LootItemStorage* LootItemStorage::instance()
|
||||
return &instance;
|
||||
}
|
||||
|
||||
boost::shared_mutex* LootItemStorage::GetLock()
|
||||
std::shared_mutex* LootItemStorage::GetLock()
|
||||
{
|
||||
static boost::shared_mutex _lock;
|
||||
static std::shared_mutex _lock;
|
||||
return &_lock;
|
||||
}
|
||||
|
||||
@@ -140,7 +137,7 @@ bool LootItemStorage::LoadStoredLoot(Item* item, Player* player)
|
||||
|
||||
// read
|
||||
{
|
||||
boost::shared_lock<boost::shared_mutex> lock(*GetLock());
|
||||
std::shared_lock<std::shared_mutex> lock(*GetLock());
|
||||
|
||||
auto itr = _lootItemStore.find(loot->containerID);
|
||||
if (itr == _lootItemStore.end())
|
||||
@@ -191,7 +188,7 @@ bool LootItemStorage::LoadStoredLoot(Item* item, Player* player)
|
||||
void LootItemStorage::RemoveStoredMoneyForContainer(uint32 containerId)
|
||||
{
|
||||
// write
|
||||
boost::unique_lock<boost::shared_mutex> lock(*GetLock());
|
||||
std::unique_lock<std::shared_mutex> lock(*GetLock());
|
||||
|
||||
auto itr = _lootItemStore.find(containerId);
|
||||
if (itr == _lootItemStore.end())
|
||||
@@ -204,7 +201,7 @@ void LootItemStorage::RemoveStoredLootForContainer(uint32 containerId)
|
||||
{
|
||||
// write
|
||||
{
|
||||
boost::unique_lock<boost::shared_mutex> lock(*GetLock());
|
||||
std::unique_lock<std::shared_mutex> lock(*GetLock());
|
||||
_lootItemStore.erase(containerId);
|
||||
}
|
||||
|
||||
@@ -223,7 +220,7 @@ void LootItemStorage::RemoveStoredLootForContainer(uint32 containerId)
|
||||
void LootItemStorage::RemoveStoredLootItemForContainer(uint32 containerId, uint32 itemId, uint32 count)
|
||||
{
|
||||
// write
|
||||
boost::unique_lock<boost::shared_mutex> lock(*GetLock());
|
||||
std::unique_lock<std::shared_mutex> lock(*GetLock());
|
||||
|
||||
auto itr = _lootItemStore.find(containerId);
|
||||
if (itr == _lootItemStore.end())
|
||||
@@ -240,7 +237,7 @@ void LootItemStorage::AddNewStoredLoot(Loot* loot, Player* player)
|
||||
|
||||
// read
|
||||
{
|
||||
boost::shared_lock<boost::shared_mutex> lock(*GetLock());
|
||||
std::shared_lock<std::shared_mutex> lock(*GetLock());
|
||||
|
||||
auto itr = _lootItemStore.find(loot->containerID);
|
||||
if (itr != _lootItemStore.end())
|
||||
@@ -282,7 +279,7 @@ void LootItemStorage::AddNewStoredLoot(Loot* loot, Player* player)
|
||||
|
||||
// write
|
||||
{
|
||||
boost::unique_lock<boost::shared_mutex> lock(*GetLock());
|
||||
std::unique_lock<std::shared_mutex> lock(*GetLock());
|
||||
_lootItemStore.emplace(loot->containerID, std::move(container));
|
||||
}
|
||||
}
|
||||
|
||||
@@ -21,6 +21,7 @@
|
||||
#include "Define.h"
|
||||
#include "DatabaseEnvFwd.h"
|
||||
|
||||
#include <shared_mutex>
|
||||
#include <unordered_map>
|
||||
|
||||
class Item;
|
||||
@@ -28,11 +29,6 @@ class Player;
|
||||
struct Loot;
|
||||
struct LootItem;
|
||||
|
||||
namespace boost
|
||||
{
|
||||
class shared_mutex;
|
||||
}
|
||||
|
||||
struct StoredLootItem
|
||||
{
|
||||
explicit StoredLootItem(LootItem const& lootItem);
|
||||
@@ -76,7 +72,7 @@ class LootItemStorage
|
||||
{
|
||||
public:
|
||||
static LootItemStorage* instance();
|
||||
static boost::shared_mutex* GetLock();
|
||||
static std::shared_mutex* GetLock();
|
||||
|
||||
void LoadStorageFromDB();
|
||||
bool LoadStoredLoot(Item* item, Player* player);
|
||||
|
||||
@@ -167,7 +167,7 @@ void WardenCheckMgr::LoadWardenOverrides()
|
||||
|
||||
uint32 count = 0;
|
||||
|
||||
boost::unique_lock<boost::shared_mutex> lock(sWardenCheckMgr->_checkStoreLock);
|
||||
std::unique_lock<std::shared_mutex> lock(sWardenCheckMgr->_checkStoreLock);
|
||||
|
||||
do
|
||||
{
|
||||
|
||||
@@ -19,8 +19,7 @@
|
||||
#define _WARDENCHECKMGR_H
|
||||
|
||||
#include <map>
|
||||
#include <boost/thread/locks.hpp>
|
||||
#include <boost/thread/shared_mutex.hpp>
|
||||
#include <shared_mutex>
|
||||
#include "Cryptography/BigNumber.h"
|
||||
|
||||
enum WardenActions
|
||||
@@ -69,7 +68,7 @@ class TC_GAME_API WardenCheckMgr
|
||||
void LoadWardenChecks();
|
||||
void LoadWardenOverrides();
|
||||
|
||||
boost::shared_mutex _checkStoreLock;
|
||||
std::shared_mutex _checkStoreLock;
|
||||
|
||||
private:
|
||||
CheckContainer CheckStore;
|
||||
|
||||
@@ -206,7 +206,7 @@ void WardenWin::RequestData()
|
||||
ByteBuffer buff;
|
||||
buff << uint8(WARDEN_SMSG_CHEAT_CHECKS_REQUEST);
|
||||
|
||||
boost::shared_lock<boost::shared_mutex> lock(sWardenCheckMgr->_checkStoreLock);
|
||||
std::shared_lock<std::shared_mutex> lock(sWardenCheckMgr->_checkStoreLock);
|
||||
|
||||
for (uint32 i = 0; i < sWorld->getIntConfig(CONFIG_WARDEN_NUM_OTHER_CHECKS); ++i)
|
||||
{
|
||||
@@ -369,7 +369,7 @@ void WardenWin::HandleData(ByteBuffer &buff)
|
||||
uint8 type;
|
||||
uint16 checkFailed = 0;
|
||||
|
||||
boost::shared_lock<boost::shared_mutex> lock(sWardenCheckMgr->_checkStoreLock);
|
||||
std::shared_lock<std::shared_mutex> lock(sWardenCheckMgr->_checkStoreLock);
|
||||
|
||||
for (std::list<uint16>::iterator itr = _currentChecks.begin(); itr != _currentChecks.end(); ++itr)
|
||||
{
|
||||
|
||||
@@ -33,8 +33,6 @@ EndScriptData */
|
||||
#include "Realm.h"
|
||||
#include "World.h"
|
||||
#include "WorldSession.h"
|
||||
#include <boost/thread/locks.hpp>
|
||||
#include <boost/thread/shared_mutex.hpp>
|
||||
|
||||
class gm_commandscript : public CommandScript
|
||||
{
|
||||
@@ -126,7 +124,7 @@ public:
|
||||
bool first = true;
|
||||
bool footer = false;
|
||||
|
||||
boost::shared_lock<boost::shared_mutex> lock(*HashMapHolder<Player>::GetLock());
|
||||
std::shared_lock<std::shared_mutex> lock(*HashMapHolder<Player>::GetLock());
|
||||
HashMapHolder<Player>::MapType const& m = ObjectAccessor::GetPlayers();
|
||||
for (HashMapHolder<Player>::MapType::const_iterator itr = m.begin(); itr != m.end(); ++itr)
|
||||
{
|
||||
|
||||
@@ -34,8 +34,6 @@ EndScriptData */
|
||||
#include "RBAC.h"
|
||||
#include "World.h"
|
||||
#include "WorldSession.h"
|
||||
#include <boost/thread/locks.hpp>
|
||||
#include <boost/thread/shared_mutex.hpp>
|
||||
|
||||
class reset_commandscript : public CommandScript
|
||||
{
|
||||
@@ -302,7 +300,7 @@ public:
|
||||
stmt->setUInt16(0, uint16(atLogin));
|
||||
CharacterDatabase.Execute(stmt);
|
||||
|
||||
boost::shared_lock<boost::shared_mutex> lock(*HashMapHolder<Player>::GetLock());
|
||||
std::shared_lock<std::shared_mutex> lock(*HashMapHolder<Player>::GetLock());
|
||||
HashMapHolder<Player>::MapType const& plist = ObjectAccessor::GetPlayers();
|
||||
for (HashMapHolder<Player>::MapType::const_iterator itr = plist.begin(); itr != plist.end(); ++itr)
|
||||
itr->second->SetAtLoginFlag(atLogin);
|
||||
|
||||
Reference in New Issue
Block a user