mirror of
https://github.com/mod-playerbots/azerothcore-wotlk.git
synced 2026-01-22 21:26:23 +00:00
feat(Core/Threading): replace ace threading (#4821)
This commit is contained in:
@@ -178,9 +178,6 @@ void PlayerMenu::ClearMenus()
|
||||
|
||||
void PlayerMenu::SendGossipMenu(uint32 titleTextId, uint64 objectGUID) const
|
||||
{
|
||||
//ACE_Read_Guard<ACE_RW_Thread_Mutex> lock1(_gossipMenu.GetLock());
|
||||
//ACE_Read_Guard<ACE_RW_Thread_Mutex> lock2(_questMenu.GetLock());
|
||||
|
||||
WorldPacket data(SMSG_GOSSIP_MESSAGE, 24 + _gossipMenu.GetMenuItemCount() * 100 + _questMenu.GetMenuItemCount() * 75); // guess size
|
||||
data << uint64(objectGUID);
|
||||
data << uint32(_gossipMenu.GetMenuId()); // new 2.4.0
|
||||
|
||||
@@ -5815,8 +5815,8 @@ void Player::ClearChannelWatch()
|
||||
void Player::UpdateLocalChannels(uint32 newZone)
|
||||
{
|
||||
// pussywizard: mutex needed (tc changed opcode to THREAD UNSAFE)
|
||||
static ACE_Thread_Mutex channelsLock;
|
||||
ACORE_GUARD(ACE_Thread_Mutex, channelsLock);
|
||||
static std::mutex channelsLock;
|
||||
std::lock_guard<std::mutex> guard(channelsLock);
|
||||
|
||||
if (GetSession()->PlayerLoading() && !IsBeingTeleportedFar())
|
||||
return; // The client handles it automatically after loading, but not after teleporting
|
||||
@@ -14361,7 +14361,7 @@ void Player::TradeCancel(bool sendback)
|
||||
|
||||
void Player::UpdateSoulboundTradeItems()
|
||||
{
|
||||
ACORE_GUARD(ACE_Thread_Mutex, m_soulboundTradableLock);
|
||||
std::lock_guard<std::mutex> guard(m_soulboundTradableLock);
|
||||
if (m_itemSoulboundTradeable.empty())
|
||||
return;
|
||||
|
||||
@@ -14385,14 +14385,14 @@ void Player::UpdateSoulboundTradeItems()
|
||||
|
||||
void Player::AddTradeableItem(Item* item)
|
||||
{
|
||||
ACORE_GUARD(ACE_Thread_Mutex, m_soulboundTradableLock);
|
||||
std::lock_guard<std::mutex> guard(m_soulboundTradableLock);
|
||||
m_itemSoulboundTradeable.push_back(item);
|
||||
}
|
||||
|
||||
//TODO: should never allow an item to be added to m_itemSoulboundTradeable twice
|
||||
void Player::RemoveTradeableItem(Item* item)
|
||||
{
|
||||
ACORE_GUARD(ACE_Thread_Mutex, m_soulboundTradableLock);
|
||||
std::lock_guard<std::mutex> guard(m_soulboundTradableLock);
|
||||
m_itemSoulboundTradeable.remove(item);
|
||||
}
|
||||
|
||||
|
||||
@@ -2821,7 +2821,7 @@ protected:
|
||||
EnchantDurationList m_enchantDuration;
|
||||
ItemDurationList m_itemDuration;
|
||||
ItemDurationList m_itemSoulboundTradeable;
|
||||
ACE_Thread_Mutex m_soulboundTradableLock;
|
||||
std::mutex m_soulboundTradableLock;
|
||||
|
||||
void ResetTimeSync();
|
||||
void SendTimeSync();
|
||||
|
||||
@@ -250,7 +250,7 @@ void MotionTransport::UpdatePosition(float x, float y, float z, float o)
|
||||
|
||||
void MotionTransport::AddPassenger(WorldObject* passenger, bool withAll)
|
||||
{
|
||||
ACORE_GUARD(ACE_Thread_Mutex, Lock);
|
||||
std::lock_guard<std::mutex> guard(Lock);
|
||||
if (_passengers.insert(passenger).second)
|
||||
{
|
||||
if (Player* plr = passenger->ToPlayer())
|
||||
@@ -279,7 +279,7 @@ void MotionTransport::AddPassenger(WorldObject* passenger, bool withAll)
|
||||
|
||||
void MotionTransport::RemovePassenger(WorldObject* passenger, bool withAll)
|
||||
{
|
||||
ACORE_GUARD(ACE_Thread_Mutex, Lock);
|
||||
std::lock_guard<std::mutex> guard(Lock);
|
||||
if (_passengers.erase(passenger) || _staticPassengers.erase(passenger))
|
||||
{
|
||||
if (Player* plr = passenger->ToPlayer())
|
||||
|
||||
@@ -91,7 +91,7 @@ private:
|
||||
bool _triggeredDepartureEvent;
|
||||
|
||||
PassengerSet _staticPassengers;
|
||||
mutable ACE_Thread_Mutex Lock;
|
||||
mutable std::mutex Lock;
|
||||
bool _passengersLoaded;
|
||||
bool _delayedTeleport;
|
||||
};
|
||||
|
||||
@@ -1710,14 +1710,14 @@ void GameEventMgr::RunSmartAIScripts(uint16 event_id, bool activate)
|
||||
//! Iterate over every supported source type (creature and gameobject)
|
||||
//! Not entirely sure how this will affect units in non-loaded grids.
|
||||
{
|
||||
ACORE_READ_GUARD(HashMapHolder<Creature>::LockType, *HashMapHolder<Creature>::GetLock());
|
||||
std::shared_lock<std::shared_mutex> lock(*HashMapHolder<Creature>::GetLock());
|
||||
HashMapHolder<Creature>::MapType const& m = ObjectAccessor::GetCreatures();
|
||||
for (HashMapHolder<Creature>::MapType::const_iterator iter = m.begin(); iter != m.end(); ++iter)
|
||||
if (iter->second->IsInWorld() && !iter->second->IsDuringRemoveFromWorld() && iter->second->FindMap() && iter->second->IsAIEnabled && iter->second->AI())
|
||||
iter->second->AI()->sOnGameEvent(activate, event_id);
|
||||
}
|
||||
{
|
||||
ACORE_READ_GUARD(HashMapHolder<GameObject>::LockType, *HashMapHolder<GameObject>::GetLock());
|
||||
std::shared_lock<std::shared_mutex> lock(*HashMapHolder<GameObject>::GetLock());
|
||||
HashMapHolder<GameObject>::MapType const& m = ObjectAccessor::GetGameObjects();
|
||||
for (HashMapHolder<GameObject>::MapType::const_iterator iter = m.begin(); iter != m.end(); ++iter)
|
||||
if (iter->second->IsInWorld() && iter->second->FindMap() && iter->second->AI())
|
||||
|
||||
@@ -26,6 +26,35 @@
|
||||
#include "WorldPacket.h"
|
||||
#include <cmath>
|
||||
|
||||
template<class T>
|
||||
void HashMapHolder<T>::Insert(T* o)
|
||||
{
|
||||
std::unique_lock<std::shared_mutex> lock(*GetLock());
|
||||
m_objectMap[o->GetGUID()] = o;
|
||||
}
|
||||
|
||||
template<class T>
|
||||
void HashMapHolder<T>::Remove(T* o)
|
||||
{
|
||||
std::unique_lock<std::shared_mutex> lock(*GetLock());
|
||||
m_objectMap.erase(o->GetGUID());
|
||||
}
|
||||
|
||||
template<class T>
|
||||
T* HashMapHolder<T>::Find(uint64 guid)
|
||||
{
|
||||
std::shared_lock<std::shared_mutex> lock(*GetLock());
|
||||
typename MapType::iterator itr = m_objectMap.find(guid);
|
||||
return (itr != m_objectMap.end()) ? itr->second : nullptr;
|
||||
}
|
||||
|
||||
template<class T>
|
||||
std::shared_mutex* HashMapHolder<T>::GetLock()
|
||||
{
|
||||
static std::shared_mutex _lock;
|
||||
return &_lock;
|
||||
}
|
||||
|
||||
ObjectAccessor::ObjectAccessor()
|
||||
{
|
||||
}
|
||||
@@ -190,20 +219,6 @@ Player* ObjectAccessor::FindConnectedPlayer(uint64 const& guid)
|
||||
|
||||
Player* ObjectAccessor::FindPlayerByName(std::string const& name, bool checkInWorld)
|
||||
{
|
||||
/*ACORE_READ_GUARD(HashMapHolder<Player>::LockType, *HashMapHolder<Player>::GetLock());
|
||||
std::string nameStr = name;
|
||||
std::transform(nameStr.begin(), nameStr.end(), nameStr.begin(), ::tolower);
|
||||
HashMapHolder<Player>::MapType const& m = GetPlayers();
|
||||
for (HashMapHolder<Player>::MapType::const_iterator iter = m.begin(); iter != m.end(); ++iter)
|
||||
{
|
||||
if (!iter->second->IsInWorld())
|
||||
continue;
|
||||
std::string currentName = iter->second->GetName();
|
||||
std::transform(currentName.begin(), currentName.end(), currentName.begin(), ::tolower);
|
||||
if (nameStr.compare(currentName) == 0)
|
||||
return iter->second;
|
||||
}*/
|
||||
|
||||
// pussywizard: optimization
|
||||
std::string nameStr = name;
|
||||
std::transform(nameStr.begin(), nameStr.end(), nameStr.begin(), ::tolower);
|
||||
@@ -217,7 +232,8 @@ Player* ObjectAccessor::FindPlayerByName(std::string const& name, bool checkInWo
|
||||
|
||||
void ObjectAccessor::SaveAllPlayers()
|
||||
{
|
||||
ACORE_READ_GUARD(HashMapHolder<Player>::LockType, *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)
|
||||
itr->second->SaveToDB(false, false);
|
||||
@@ -225,7 +241,7 @@ void ObjectAccessor::SaveAllPlayers()
|
||||
|
||||
Corpse* ObjectAccessor::GetCorpseForPlayerGUID(uint64 guid)
|
||||
{
|
||||
ACORE_READ_GUARD(ACE_RW_Thread_Mutex, i_corpseLock);
|
||||
std::shared_lock<std::shared_mutex> lock(i_corpseLock);
|
||||
|
||||
Player2CorpsesMapType::iterator iter = i_player2corpse.find(guid);
|
||||
if (iter == i_player2corpse.end())
|
||||
@@ -242,7 +258,7 @@ void ObjectAccessor::RemoveCorpse(Corpse* corpse, bool final)
|
||||
|
||||
if (!final)
|
||||
{
|
||||
ACORE_WRITE_GUARD(ACE_RW_Thread_Mutex, i_corpseLock);
|
||||
std::unique_lock<std::shared_mutex> guard(i_corpseLock);
|
||||
Player2CorpsesMapType::iterator iter = i_player2corpse.find(corpse->GetOwnerGUID());
|
||||
if (iter == i_player2corpse.end())
|
||||
return;
|
||||
@@ -269,7 +285,7 @@ void ObjectAccessor::RemoveCorpse(Corpse* corpse, bool final)
|
||||
|
||||
// Critical section
|
||||
{
|
||||
ACORE_WRITE_GUARD(ACE_RW_Thread_Mutex, i_corpseLock);
|
||||
std::unique_lock<std::shared_mutex> guard(i_corpseLock);
|
||||
|
||||
// build mapid*cellid -> guid_set map
|
||||
CellCoord cellCoord = acore::ComputeCellCoord(corpse->GetPositionX(), corpse->GetPositionY());
|
||||
@@ -285,7 +301,7 @@ void ObjectAccessor::AddCorpse(Corpse* corpse)
|
||||
|
||||
// Critical section
|
||||
{
|
||||
ACORE_WRITE_GUARD(ACE_RW_Thread_Mutex, i_corpseLock);
|
||||
std::unique_lock<std::shared_mutex> guard(i_corpseLock);
|
||||
|
||||
ASSERT(i_player2corpse.find(corpse->GetOwnerGUID()) == i_player2corpse.end());
|
||||
i_player2corpse[corpse->GetOwnerGUID()] = corpse;
|
||||
@@ -298,7 +314,7 @@ void ObjectAccessor::AddCorpse(Corpse* corpse)
|
||||
|
||||
void ObjectAccessor::AddCorpsesToGrid(GridCoord const& gridpair, GridType& grid, Map* map)
|
||||
{
|
||||
ACORE_READ_GUARD(ACE_RW_Thread_Mutex, i_corpseLock);
|
||||
std::shared_lock<std::shared_mutex> guard(i_corpseLock);
|
||||
|
||||
for (Player2CorpsesMapType::iterator iter = i_player2corpse.begin(); iter != i_player2corpse.end(); ++iter)
|
||||
{
|
||||
@@ -386,7 +402,7 @@ Corpse* ObjectAccessor::ConvertCorpseForPlayer(uint64 player_guid, bool insignia
|
||||
}
|
||||
|
||||
// pussywizard: for deleting bones
|
||||
ACORE_WRITE_GUARD(ACE_RW_Thread_Mutex, i_corpseLock);
|
||||
std::unique_lock<std::shared_mutex> guard(i_corpseLock);
|
||||
i_playerBones.push_back(bones->GetGUID());
|
||||
}
|
||||
|
||||
@@ -413,7 +429,7 @@ void ObjectAccessor::RemoveOldCorpses()
|
||||
|
||||
// pussywizard: for deleting bones
|
||||
std::list<uint64>::iterator next2;
|
||||
ACORE_WRITE_GUARD(ACE_RW_Thread_Mutex, i_corpseLock);
|
||||
std::unique_lock<std::shared_mutex> guard(i_corpseLock);
|
||||
for (std::list<uint64>::iterator itr = i_playerBones.begin(); itr != i_playerBones.end(); itr = next2)
|
||||
{
|
||||
next2 = itr;
|
||||
@@ -446,13 +462,13 @@ void ObjectAccessor::RemoveOldCorpses()
|
||||
|
||||
void ObjectAccessor::AddDelayedCorpseAction(Corpse* corpse, uint8 action, uint32 mapId, uint32 instanceId)
|
||||
{
|
||||
ACORE_GUARD(ACE_Thread_Mutex, DelayedCorpseLock);
|
||||
std::lock_guard<std::mutex> guard(DelayedCorpseLock);
|
||||
i_delayedCorpseActions.push_back(DelayedCorpseAction(corpse, action, mapId, instanceId));
|
||||
}
|
||||
|
||||
void ObjectAccessor::ProcessDelayedCorpseActions()
|
||||
{
|
||||
ACORE_GUARD(ACE_Thread_Mutex, DelayedCorpseLock);
|
||||
std::lock_guard<std::mutex> guard(DelayedCorpseLock);
|
||||
for (std::list<DelayedCorpseAction>::iterator itr = i_delayedCorpseActions.begin(); itr != i_delayedCorpseActions.end(); ++itr)
|
||||
{
|
||||
DelayedCorpseAction a = (*itr);
|
||||
|
||||
@@ -11,8 +11,9 @@
|
||||
#include "GridDefines.h"
|
||||
#include "Object.h"
|
||||
#include "UpdateData.h"
|
||||
#include <ace/Thread_Mutex.h>
|
||||
#include <mutex>
|
||||
#include <set>
|
||||
#include <shared_mutex>
|
||||
#include <unordered_map>
|
||||
|
||||
class Creature;
|
||||
@@ -33,43 +34,24 @@ class HashMapHolder
|
||||
{
|
||||
public:
|
||||
typedef std::unordered_map<uint64, T*> MapType;
|
||||
typedef ACE_RW_Thread_Mutex LockType;
|
||||
|
||||
static void Insert(T* o)
|
||||
{
|
||||
ACORE_WRITE_GUARD(LockType, i_lock);
|
||||
m_objectMap[o->GetGUID()] = o;
|
||||
}
|
||||
|
||||
static void Remove(T* o)
|
||||
{
|
||||
ACORE_WRITE_GUARD(LockType, i_lock);
|
||||
m_objectMap.erase(o->GetGUID());
|
||||
}
|
||||
|
||||
static T* Find(uint64 guid)
|
||||
{
|
||||
ACORE_READ_GUARD(LockType, i_lock);
|
||||
typename MapType::iterator itr = m_objectMap.find(guid);
|
||||
return (itr != m_objectMap.end()) ? itr->second : nullptr;
|
||||
}
|
||||
static void Insert(T* o);
|
||||
static void Remove(T* o);
|
||||
static T* Find(uint64 guid);
|
||||
|
||||
static MapType& GetContainer() { return m_objectMap; }
|
||||
|
||||
static LockType* GetLock() { return &i_lock; }
|
||||
static std::shared_mutex* GetLock();
|
||||
|
||||
private:
|
||||
//Non instanceable only static
|
||||
HashMapHolder() = default;
|
||||
|
||||
static LockType i_lock;
|
||||
static MapType m_objectMap;
|
||||
static MapType m_objectMap;
|
||||
};
|
||||
|
||||
/// Define the static members of HashMapHolder
|
||||
|
||||
template <class T> std::unordered_map< uint64, T* > HashMapHolder<T>::m_objectMap;
|
||||
template <class T> typename HashMapHolder<T>::LockType HashMapHolder<T>::i_lock;
|
||||
|
||||
// pussywizard:
|
||||
class DelayedCorpseAction
|
||||
@@ -226,7 +208,7 @@ public:
|
||||
//non-static functions
|
||||
void AddUpdateObject(Object* obj)
|
||||
{
|
||||
ACORE_GUARD(ACE_Thread_Mutex, i_objectLock);
|
||||
std::lock_guard<std::mutex> guard(i_objectLock);
|
||||
if (obj->GetTypeId() < TYPEID_UNIT) // these are not in map: TYPEID_OBJECT, TYPEID_ITEM, TYPEID_CONTAINER
|
||||
i_objects.insert(obj);
|
||||
else
|
||||
@@ -235,7 +217,7 @@ public:
|
||||
|
||||
void RemoveUpdateObject(Object* obj)
|
||||
{
|
||||
ACORE_GUARD(ACE_Thread_Mutex, i_objectLock);
|
||||
std::lock_guard<std::mutex> guard(i_objectLock);
|
||||
if (obj->GetTypeId() < TYPEID_UNIT) // these are not in map: TYPEID_OBJECT, TYPEID_ITEM, TYPEID_CONTAINER
|
||||
i_objects.erase(obj);
|
||||
else
|
||||
@@ -270,10 +252,10 @@ private:
|
||||
Player2CorpsesMapType i_player2corpse;
|
||||
std::list<uint64> i_playerBones;
|
||||
|
||||
ACE_Thread_Mutex i_objectLock;
|
||||
ACE_RW_Thread_Mutex i_corpseLock;
|
||||
std::mutex i_objectLock;
|
||||
std::shared_mutex i_corpseLock;
|
||||
std::list<DelayedCorpseAction> i_delayedCorpseActions;
|
||||
mutable ACE_Thread_Mutex DelayedCorpseLock;
|
||||
mutable std::mutex DelayedCorpseLock;
|
||||
};
|
||||
|
||||
#define sObjectAccessor ObjectAccessor::instance()
|
||||
|
||||
@@ -6508,7 +6508,7 @@ uint32 ObjectMgr::GenerateMailID()
|
||||
sLog->outError("Mail ids overflow!! Can't continue, shutting down server. ");
|
||||
World::StopNow(ERROR_EXIT_CODE);
|
||||
}
|
||||
ACORE_GUARD(ACE_Thread_Mutex, _mailIdMutex);
|
||||
std::lock_guard<std::mutex> guard(_mailIdMutex);
|
||||
return _mailId++;
|
||||
}
|
||||
|
||||
@@ -6519,25 +6519,25 @@ uint32 ObjectMgr::GenerateLowGuid(HighGuid guidhigh)
|
||||
case HIGHGUID_ITEM:
|
||||
{
|
||||
ASSERT(_hiItemGuid < 0xFFFFFFFE && "Item guid overflow!");
|
||||
ACORE_GUARD(ACE_Thread_Mutex, _hiItemGuidMutex);
|
||||
std::lock_guard<std::mutex> guard(_hiItemGuidMutex);
|
||||
return _hiItemGuid++;
|
||||
}
|
||||
case HIGHGUID_UNIT:
|
||||
{
|
||||
ASSERT(_hiCreatureGuid < 0x00FFFFFE && "Creature guid overflow!");
|
||||
ACORE_GUARD(ACE_Thread_Mutex, _hiCreatureGuidMutex);
|
||||
std::lock_guard<std::mutex> guard(_hiCreatureGuidMutex);
|
||||
return _hiCreatureGuid++;
|
||||
}
|
||||
case HIGHGUID_PET:
|
||||
{
|
||||
ASSERT(_hiPetGuid < 0x00FFFFFE && "Pet guid overflow!");
|
||||
ACORE_GUARD(ACE_Thread_Mutex, _hiPetGuidMutex);
|
||||
std::lock_guard<std::mutex> guard(_hiPetGuidMutex);
|
||||
return _hiPetGuid++;
|
||||
}
|
||||
case HIGHGUID_VEHICLE:
|
||||
{
|
||||
ASSERT(_hiVehicleGuid < 0x00FFFFFF && "Vehicle guid overflow!");
|
||||
ACORE_GUARD(ACE_Thread_Mutex, _hiVehicleGuidMutex);
|
||||
std::lock_guard<std::mutex> guard(_hiVehicleGuidMutex);
|
||||
return _hiVehicleGuid++;
|
||||
}
|
||||
case HIGHGUID_PLAYER:
|
||||
@@ -6548,25 +6548,25 @@ uint32 ObjectMgr::GenerateLowGuid(HighGuid guidhigh)
|
||||
case HIGHGUID_GAMEOBJECT:
|
||||
{
|
||||
ASSERT(_hiGoGuid < 0x00FFFFFE && "Gameobject guid overflow!");
|
||||
ACORE_GUARD(ACE_Thread_Mutex, _hiGoGuidMutex);
|
||||
std::lock_guard<std::mutex> guard(_hiGoGuidMutex);
|
||||
return _hiGoGuid++;
|
||||
}
|
||||
case HIGHGUID_CORPSE:
|
||||
{
|
||||
ASSERT(_hiCorpseGuid < 0xFFFFFFFE && "Corpse guid overflow!");
|
||||
ACORE_GUARD(ACE_Thread_Mutex, _hiCorpseGuidMutex);
|
||||
std::lock_guard<std::mutex> guard(_hiCorpseGuidMutex);
|
||||
return _hiCorpseGuid++;
|
||||
}
|
||||
case HIGHGUID_DYNAMICOBJECT:
|
||||
{
|
||||
ASSERT(_hiDoGuid < 0xFFFFFFFE && "DynamicObject guid overflow!");
|
||||
ACORE_GUARD(ACE_Thread_Mutex, _hiDoGuidMutex);
|
||||
std::lock_guard<std::mutex> guard(_hiDoGuidMutex);
|
||||
return _hiDoGuid++;
|
||||
}
|
||||
case HIGHGUID_MO_TRANSPORT:
|
||||
{
|
||||
ASSERT(_hiMoTransGuid < 0xFFFFFFFE && "MO Transport guid overflow!");
|
||||
ACORE_GUARD(ACE_Thread_Mutex, _hiMoTransGuidMutex);
|
||||
std::lock_guard<std::mutex> guard(_hiMoTransGuidMutex);
|
||||
return _hiMoTransGuid++;
|
||||
}
|
||||
default:
|
||||
@@ -7047,7 +7047,7 @@ std::string ObjectMgr::GeneratePetName(uint32 entry)
|
||||
|
||||
uint32 ObjectMgr::GeneratePetNumber()
|
||||
{
|
||||
ACORE_GUARD(ACE_Thread_Mutex, _hiPetNumberMutex);
|
||||
std::lock_guard<std::mutex> guard(_hiPetNumberMutex);
|
||||
return ++_hiPetNumber;
|
||||
}
|
||||
|
||||
|
||||
@@ -1353,28 +1353,28 @@ private:
|
||||
uint64 _equipmentSetGuid; // pussywizard: accessed by a single thread
|
||||
uint32 _itemTextId; // pussywizard: unused? xD
|
||||
uint32 _mailId;
|
||||
ACE_Thread_Mutex _mailIdMutex;
|
||||
std::mutex _mailIdMutex;
|
||||
uint32 _hiPetNumber;
|
||||
ACE_Thread_Mutex _hiPetNumberMutex;
|
||||
std::mutex _hiPetNumberMutex;
|
||||
|
||||
// first free low guid for selected guid type
|
||||
uint32 _hiCharGuid; // pussywizard: accessed by a single thread
|
||||
uint32 _hiCreatureGuid;
|
||||
ACE_Thread_Mutex _hiCreatureGuidMutex;
|
||||
std::mutex _hiCreatureGuidMutex;
|
||||
uint32 _hiPetGuid;
|
||||
ACE_Thread_Mutex _hiPetGuidMutex;
|
||||
std::mutex _hiPetGuidMutex;
|
||||
uint32 _hiVehicleGuid;
|
||||
ACE_Thread_Mutex _hiVehicleGuidMutex;
|
||||
std::mutex _hiVehicleGuidMutex;
|
||||
uint32 _hiItemGuid;
|
||||
ACE_Thread_Mutex _hiItemGuidMutex;
|
||||
std::mutex _hiItemGuidMutex;
|
||||
uint32 _hiGoGuid;
|
||||
ACE_Thread_Mutex _hiGoGuidMutex;
|
||||
std::mutex _hiGoGuidMutex;
|
||||
uint32 _hiDoGuid;
|
||||
ACE_Thread_Mutex _hiDoGuidMutex;
|
||||
std::mutex _hiDoGuidMutex;
|
||||
uint32 _hiCorpseGuid;
|
||||
ACE_Thread_Mutex _hiCorpseGuidMutex;
|
||||
std::mutex _hiCorpseGuidMutex;
|
||||
uint32 _hiMoTransGuid;
|
||||
ACE_Thread_Mutex _hiMoTransGuidMutex;
|
||||
std::mutex _hiMoTransGuidMutex;
|
||||
|
||||
uint32 _hiCreatureRecycledGuidMax;
|
||||
uint32 _hiCreatureRecycledGuid;
|
||||
|
||||
@@ -749,7 +749,7 @@ void WorldSession::HandleAuctionListItems(WorldPacket& recvData)
|
||||
if (diff > delay)
|
||||
diff = delay;
|
||||
_lastAuctionListItemsMSTime = now + delay - diff;
|
||||
ACORE_GUARD(ACE_Thread_Mutex, AsyncAuctionListingMgr::GetTempLock());
|
||||
std::lock_guard<std::mutex> guard(AsyncAuctionListingMgr::GetTempLock());
|
||||
AsyncAuctionListingMgr::GetTempList().push_back( AuctionListItemsDelayEvent(delay - diff, _player->GetGUID(), guid, searchedname, listfrom, levelmin, levelmax, usable, auctionSlotID, auctionMainCategory, auctionSubCategory, quality, getAll) );
|
||||
}
|
||||
|
||||
|
||||
@@ -291,7 +291,7 @@ void WorldSession::HandleWhoOpcode(WorldPacket& recvData)
|
||||
data << uint32(matchcount); // placeholder, count of players matching criteria
|
||||
data << uint32(displaycount); // placeholder, count of players displayed
|
||||
|
||||
ACORE_READ_GUARD(HashMapHolder<Player>::LockType, *HashMapHolder<Player>::GetLock());
|
||||
std::shared_lock<std::shared_mutex> lock(*HashMapHolder<Player>::GetLock());
|
||||
HashMapHolder<Player>::MapType const& m = sObjectAccessor->GetPlayers();
|
||||
for (HashMapHolder<Player>::MapType::const_iterator itr = m.begin(); itr != m.end(); ++itr)
|
||||
{
|
||||
|
||||
@@ -199,13 +199,13 @@ MapEntry const* InstanceSave::GetMapEntry()
|
||||
|
||||
void InstanceSave::AddPlayer(uint32 guidLow)
|
||||
{
|
||||
ACORE_GUARD(ACE_Thread_Mutex, _lock);
|
||||
std::lock_guard<std::mutex> guard(_lock);
|
||||
m_playerList.push_back(guidLow);
|
||||
}
|
||||
|
||||
bool InstanceSave::RemovePlayer(uint32 guidLow, InstanceSaveManager* ism)
|
||||
{
|
||||
ACORE_GUARD(ACE_Thread_Mutex, _lock);
|
||||
std::lock_guard<std::mutex> guard(_lock);
|
||||
m_playerList.remove(guidLow);
|
||||
|
||||
// ism passed as an argument to avoid calling via singleton (might result in a deadlock)
|
||||
|
||||
@@ -11,10 +11,9 @@
|
||||
#include "DBCEnums.h"
|
||||
#include "Define.h"
|
||||
#include "ObjectDefines.h"
|
||||
#include <ace/Null_Mutex.h>
|
||||
#include <ace/Thread_Mutex.h>
|
||||
#include <list>
|
||||
#include <map>
|
||||
#include <mutex>
|
||||
#include <unordered_map>
|
||||
|
||||
struct InstanceTemplate;
|
||||
@@ -88,7 +87,7 @@ private:
|
||||
std::string m_instanceData;
|
||||
uint32 m_completedEncounterMask;
|
||||
|
||||
ACE_Thread_Mutex _lock;
|
||||
std::mutex _lock;
|
||||
};
|
||||
|
||||
typedef std::unordered_map<uint32 /*PAIR32(map, difficulty)*/, time_t /*resetTime*/> ResetTimeByMapDifficultyMap;
|
||||
|
||||
@@ -404,7 +404,7 @@ void Map::EnsureGridCreated(const GridCoord& p)
|
||||
{
|
||||
if (getNGrid(p.x_coord, p.y_coord)) // pussywizard
|
||||
return;
|
||||
ACORE_GUARD(ACE_Thread_Mutex, GridLock);
|
||||
std::lock_guard<std::mutex> guard(GridLock);
|
||||
EnsureGridCreated_i(p);
|
||||
}
|
||||
|
||||
|
||||
@@ -20,10 +20,10 @@
|
||||
#include "PathGenerator.h"
|
||||
#include "SharedDefines.h"
|
||||
#include "Timer.h"
|
||||
#include <ace/RW_Thread_Mutex.h>
|
||||
#include <ace/Thread_Mutex.h>
|
||||
#include <bitset>
|
||||
#include <list>
|
||||
#include <mutex>
|
||||
#include <shared_mutex>
|
||||
|
||||
class Unit;
|
||||
class WorldPacket;
|
||||
@@ -338,7 +338,7 @@ public:
|
||||
[[nodiscard]] Map const* GetParent() const { return m_parentMap; }
|
||||
|
||||
// pussywizard: movemaps, mmaps
|
||||
[[nodiscard]] ACE_RW_Thread_Mutex& GetMMapLock() const { return *(const_cast<ACE_RW_Thread_Mutex*>(&MMapLock)); }
|
||||
[[nodiscard]] std::shared_mutex& GetMMapLock() const { return *(const_cast<std::shared_mutex*>(&MMapLock)); }
|
||||
// pussywizard:
|
||||
std::unordered_set<Object*> i_objectsToUpdate;
|
||||
void BuildAndSendUpdateForObjects(); // definition in ObjectAccessor.cpp, below ObjectAccessor::Update, because it does the same for a map
|
||||
@@ -580,9 +580,9 @@ private:
|
||||
void UpdateActiveCells(const float& x, const float& y, const uint32 t_diff);
|
||||
|
||||
protected:
|
||||
ACE_Thread_Mutex Lock;
|
||||
ACE_Thread_Mutex GridLock;
|
||||
ACE_RW_Thread_Mutex MMapLock;
|
||||
std::mutex Lock;
|
||||
std::mutex GridLock;
|
||||
std::shared_mutex MMapLock;
|
||||
|
||||
MapEntry const* i_mapEntry;
|
||||
uint8 i_spawnMode;
|
||||
|
||||
@@ -175,7 +175,7 @@ Map* MapInstanced::CreateInstanceForPlayer(const uint32 mapId, Player* player)
|
||||
InstanceMap* MapInstanced::CreateInstance(uint32 InstanceId, InstanceSave* save, Difficulty difficulty)
|
||||
{
|
||||
// load/create a map
|
||||
ACORE_GUARD(ACE_Thread_Mutex, Lock);
|
||||
std::lock_guard<std::mutex> guard(Lock);
|
||||
|
||||
// make sure we have a valid map id
|
||||
const MapEntry* entry = sMapStore.LookupEntry(GetId());
|
||||
@@ -218,7 +218,7 @@ InstanceMap* MapInstanced::CreateInstance(uint32 InstanceId, InstanceSave* save,
|
||||
BattlegroundMap* MapInstanced::CreateBattleground(uint32 InstanceId, Battleground* bg)
|
||||
{
|
||||
// load/create a map
|
||||
ACORE_GUARD(ACE_Thread_Mutex, Lock);
|
||||
std::lock_guard<std::mutex> guard(Lock);
|
||||
|
||||
#if defined(ENABLE_EXTRAS) && defined(ENABLE_EXTRA_LOGS)
|
||||
sLog->outDebug(LOG_FILTER_MAPS, "MapInstanced::CreateBattleground: map bg %d for %d created.", InstanceId, GetId());
|
||||
|
||||
@@ -71,7 +71,7 @@ Map* MapManager::CreateBaseMap(uint32 id)
|
||||
|
||||
if (map == nullptr)
|
||||
{
|
||||
ACORE_GUARD(ACE_Thread_Mutex, Lock);
|
||||
std::lock_guard<std::mutex> guard(Lock);
|
||||
|
||||
map = FindBaseMap(id);
|
||||
if (map == nullptr) // pussywizard: check again after acquiring mutex
|
||||
|
||||
@@ -12,7 +12,7 @@
|
||||
#include "Map.h"
|
||||
#include "MapUpdater.h"
|
||||
#include "Object.h"
|
||||
#include <ace/Thread_Mutex.h>
|
||||
#include <mutex>
|
||||
|
||||
class Transport;
|
||||
class StaticTransport;
|
||||
@@ -130,7 +130,7 @@ private:
|
||||
MapManager(const MapManager&);
|
||||
MapManager& operator=(const MapManager&);
|
||||
|
||||
ACE_Thread_Mutex Lock;
|
||||
std::mutex Lock;
|
||||
MapMapType i_maps;
|
||||
IntervalTimer i_timer[4]; // continents, bgs/arenas, instances, total from the beginning
|
||||
uint8 mapUpdateStep;
|
||||
|
||||
@@ -10,8 +10,8 @@ uint32 AsyncAuctionListingMgr::auctionListingDiff = 0;
|
||||
bool AsyncAuctionListingMgr::auctionListingAllowed = false;
|
||||
std::list<AuctionListItemsDelayEvent> AsyncAuctionListingMgr::auctionListingList;
|
||||
std::list<AuctionListItemsDelayEvent> AsyncAuctionListingMgr::auctionListingListTemp;
|
||||
ACE_Thread_Mutex AsyncAuctionListingMgr::auctionListingLock;
|
||||
ACE_Thread_Mutex AsyncAuctionListingMgr::auctionListingTempLock;
|
||||
std::mutex AsyncAuctionListingMgr::auctionListingLock;
|
||||
std::mutex AsyncAuctionListingMgr::auctionListingTempLock;
|
||||
|
||||
bool AuctionListOwnerItemsDelayEvent::Execute(uint64 /*e_time*/, uint32 /*p_time*/)
|
||||
{
|
||||
|
||||
@@ -55,16 +55,16 @@ public:
|
||||
|
||||
static std::list<AuctionListItemsDelayEvent>& GetList() { return auctionListingList; }
|
||||
static std::list<AuctionListItemsDelayEvent>& GetTempList() { return auctionListingListTemp; }
|
||||
static ACE_Thread_Mutex& GetLock() { return auctionListingLock; }
|
||||
static ACE_Thread_Mutex& GetTempLock() { return auctionListingTempLock; }
|
||||
static std::mutex& GetLock() { return auctionListingLock; }
|
||||
static std::mutex& GetTempLock() { return auctionListingTempLock; }
|
||||
|
||||
private:
|
||||
static uint32 auctionListingDiff;
|
||||
static bool auctionListingAllowed;
|
||||
static std::list<AuctionListItemsDelayEvent> auctionListingList;
|
||||
static std::list<AuctionListItemsDelayEvent> auctionListingListTemp;
|
||||
static ACE_Thread_Mutex auctionListingLock;
|
||||
static ACE_Thread_Mutex auctionListingTempLock;
|
||||
static std::mutex auctionListingLock;
|
||||
static std::mutex auctionListingTempLock;
|
||||
};
|
||||
|
||||
#endif
|
||||
|
||||
@@ -5,7 +5,7 @@ uint32 SavingSystemMgr::m_savingCurrentValue = 0;
|
||||
uint32 SavingSystemMgr::m_savingMaxValueAssigned = 0;
|
||||
uint32 SavingSystemMgr::m_savingDiffSum = 0;
|
||||
std::list<uint32> SavingSystemMgr::m_savingSkipList;
|
||||
ACE_Thread_Mutex SavingSystemMgr::_savingLock;
|
||||
std::mutex SavingSystemMgr::_savingLock;
|
||||
|
||||
void SavingSystemMgr::Update(uint32 diff)
|
||||
{
|
||||
|
||||
@@ -13,15 +13,15 @@ public:
|
||||
static uint32 GetSavingCurrentValue() { return m_savingCurrentValue; } // modified only during single thread
|
||||
static uint32 GetSavingMaxValue() { return m_savingMaxValueAssigned; } // modified only during single thread
|
||||
static void IncreaseSavingCurrentValue(uint32 inc) { m_savingCurrentValue += inc; } // used and modified only during single thread
|
||||
static uint32 IncreaseSavingMaxValue(uint32 inc) { ACORE_GUARD(ACE_Thread_Mutex, _savingLock); return (m_savingMaxValueAssigned += inc); }
|
||||
static void InsertToSavingSkipListIfNeeded(uint32 id) { if (id > m_savingCurrentValue) { ACORE_GUARD(ACE_Thread_Mutex, _savingLock); m_savingSkipList.push_back(id); } }
|
||||
static uint32 IncreaseSavingMaxValue(uint32 inc) { std::lock_guard<std::mutex> guard(_savingLock); return (m_savingMaxValueAssigned += inc); }
|
||||
static void InsertToSavingSkipListIfNeeded(uint32 id) { if (id > m_savingCurrentValue) { std::lock_guard<std::mutex> guard(_savingLock); m_savingSkipList.push_back(id); } }
|
||||
|
||||
protected:
|
||||
static uint32 m_savingCurrentValue;
|
||||
static uint32 m_savingMaxValueAssigned;
|
||||
static uint32 m_savingDiffSum;
|
||||
static std::list<uint32> m_savingSkipList;
|
||||
static ACE_Thread_Mutex _savingLock;
|
||||
static std::mutex _savingLock;
|
||||
};
|
||||
|
||||
#endif
|
||||
|
||||
@@ -12,7 +12,7 @@ void WhoListCacheMgr::Update()
|
||||
m_whoOpcodeList.clear();
|
||||
m_whoOpcodeList.reserve(sWorld->GetPlayerCount() + 1);
|
||||
|
||||
ACORE_READ_GUARD(HashMapHolder<Player>::LockType, *HashMapHolder<Player>::GetLock());
|
||||
std::shared_lock<std::shared_mutex> lock(*HashMapHolder<Player>::GetLock());
|
||||
HashMapHolder<Player>::MapType const& m = sObjectAccessor->GetPlayers();
|
||||
for (HashMapHolder<Player>::MapType::const_iterator itr = m.begin(); itr != m.end(); ++itr)
|
||||
{
|
||||
|
||||
@@ -8,12 +8,12 @@
|
||||
#define TRINITYSERVER_SPLINE_H
|
||||
|
||||
#include "MovementTypedefs.h"
|
||||
#include "Errors.h"
|
||||
#include <G3D/Vector3.h>
|
||||
#include <limits>
|
||||
|
||||
namespace Movement
|
||||
{
|
||||
|
||||
class SplineBase
|
||||
{
|
||||
public:
|
||||
|
||||
@@ -115,7 +115,7 @@ void OutdoorPvPMgr::HandlePlayerEnterZone(Player* player, uint32 zoneid)
|
||||
if (itr == m_OutdoorPvPMap.end())
|
||||
return;
|
||||
|
||||
ACORE_GUARD(ACE_Thread_Mutex, _lock); // pussywizard
|
||||
std::lock_guard<std::mutex> guard(_lock); // pussywizard
|
||||
|
||||
if (itr->second->HasPlayer(player))
|
||||
return;
|
||||
@@ -132,7 +132,7 @@ void OutdoorPvPMgr::HandlePlayerLeaveZone(Player* player, uint32 zoneid)
|
||||
if (itr == m_OutdoorPvPMap.end())
|
||||
return;
|
||||
|
||||
ACORE_GUARD(ACE_Thread_Mutex, _lock); // pussywizard
|
||||
std::lock_guard<std::mutex> guard(_lock); // pussywizard
|
||||
|
||||
// teleport: remove once in removefromworld, once in updatezone
|
||||
if (!itr->second->HasPlayer(player))
|
||||
@@ -188,7 +188,7 @@ ZoneScript* OutdoorPvPMgr::GetZoneScript(uint32 zoneId)
|
||||
|
||||
bool OutdoorPvPMgr::HandleOpenGo(Player* player, uint64 guid)
|
||||
{
|
||||
ACORE_GUARD(ACE_Thread_Mutex, _lock); // pussywizard
|
||||
std::lock_guard<std::mutex> guard(_lock); // pussywizard
|
||||
for (OutdoorPvPSet::iterator itr = m_OutdoorPvPSet.begin(); itr != m_OutdoorPvPSet.end(); ++itr)
|
||||
{
|
||||
if ((*itr)->HandleOpenGo(player, guid))
|
||||
@@ -199,7 +199,7 @@ bool OutdoorPvPMgr::HandleOpenGo(Player* player, uint64 guid)
|
||||
|
||||
void OutdoorPvPMgr::HandleGossipOption(Player* player, uint64 guid, uint32 gossipid)
|
||||
{
|
||||
ACORE_GUARD(ACE_Thread_Mutex, _lock); // pussywizard
|
||||
std::lock_guard<std::mutex> guard(_lock); // pussywizard
|
||||
for (OutdoorPvPSet::iterator itr = m_OutdoorPvPSet.begin(); itr != m_OutdoorPvPSet.end(); ++itr)
|
||||
{
|
||||
if ((*itr)->HandleGossipOption(player, guid, gossipid))
|
||||
|
||||
@@ -70,7 +70,7 @@ public:
|
||||
void HandleDropFlag(Player* player, uint32 spellId);
|
||||
|
||||
// pussywizard: lock required because different functions affect m_players
|
||||
ACE_Thread_Mutex _lock;
|
||||
std::mutex _lock;
|
||||
|
||||
private:
|
||||
typedef std::vector<OutdoorPvP*> OutdoorPvPSet;
|
||||
|
||||
@@ -1035,7 +1035,7 @@ private:
|
||||
AddonsList m_addonsList;
|
||||
uint32 recruiterId;
|
||||
bool isRecruiter;
|
||||
ACE_Based::LockedQueue<WorldPacket*, ACE_Thread_Mutex> _recvQueue;
|
||||
LockedQueue<WorldPacket*> _recvQueue;
|
||||
uint32 m_currentVendorEntry;
|
||||
uint64 m_currentBankerGUID;
|
||||
time_t timeWhoCommandAllowed;
|
||||
|
||||
@@ -126,7 +126,7 @@ void WorldSocket::CloseSocket(std::string const& reason)
|
||||
sLog->outDebug(LOG_FILTER_CLOSE_SOCKET, "Socket closed because of: %s", reason.c_str());
|
||||
|
||||
{
|
||||
ACE_GUARD (LockType, Guard, m_OutBufferLock);
|
||||
std::lock_guard<std::mutex> guard(m_OutBufferLock);
|
||||
|
||||
if (closing_)
|
||||
return;
|
||||
@@ -136,7 +136,7 @@ void WorldSocket::CloseSocket(std::string const& reason)
|
||||
}
|
||||
|
||||
{
|
||||
ACE_GUARD (LockType, Guard, m_SessionLock);
|
||||
std::lock_guard<std::mutex> guard(m_SessionLock);
|
||||
|
||||
m_Session = nullptr;
|
||||
}
|
||||
@@ -149,7 +149,7 @@ const std::string& WorldSocket::GetRemoteAddress(void) const
|
||||
|
||||
int WorldSocket::SendPacket(WorldPacket const& pct)
|
||||
{
|
||||
ACE_GUARD_RETURN (LockType, Guard, m_OutBufferLock, -1);
|
||||
std::lock_guard<std::mutex> guard(m_OutBufferLock);
|
||||
|
||||
if (closing_)
|
||||
return -1;
|
||||
@@ -306,20 +306,20 @@ int WorldSocket::handle_input(ACE_HANDLE)
|
||||
return Update(); // another interesting line ;)
|
||||
}
|
||||
|
||||
ACE_NOTREACHED(return -1);
|
||||
return -1;
|
||||
}
|
||||
|
||||
int WorldSocket::handle_output(ACE_HANDLE)
|
||||
{
|
||||
ACE_GUARD_RETURN (LockType, Guard, m_OutBufferLock, -1);
|
||||
|
||||
if (closing_)
|
||||
return -1;
|
||||
|
||||
std::lock_guard<std::mutex> guard(m_OutBufferLock);
|
||||
|
||||
size_t send_len = m_OutBuffer->length();
|
||||
|
||||
if (send_len == 0)
|
||||
return handle_output_queue(Guard);
|
||||
return handle_output_queue();
|
||||
|
||||
#ifdef MSG_NOSIGNAL
|
||||
ssize_t n = peer().send (m_OutBuffer->rd_ptr(), send_len, MSG_NOSIGNAL);
|
||||
@@ -332,7 +332,7 @@ int WorldSocket::handle_output(ACE_HANDLE)
|
||||
else if (n == -1)
|
||||
{
|
||||
if (errno == EWOULDBLOCK || errno == EAGAIN)
|
||||
return schedule_wakeup_output (Guard);
|
||||
return schedule_wakeup_output();
|
||||
|
||||
return -1;
|
||||
}
|
||||
@@ -343,22 +343,22 @@ int WorldSocket::handle_output(ACE_HANDLE)
|
||||
// move the data to the base of the buffer
|
||||
m_OutBuffer->crunch();
|
||||
|
||||
return schedule_wakeup_output (Guard);
|
||||
return schedule_wakeup_output();
|
||||
}
|
||||
else //now n == send_len
|
||||
{
|
||||
m_OutBuffer->reset();
|
||||
|
||||
return handle_output_queue (Guard);
|
||||
return handle_output_queue();
|
||||
}
|
||||
|
||||
ACE_NOTREACHED (return 0);
|
||||
}
|
||||
|
||||
int WorldSocket::handle_output_queue(GuardType& g)
|
||||
int WorldSocket::handle_output_queue()
|
||||
{
|
||||
if (msg_queue()->is_empty())
|
||||
return cancel_wakeup_output(g);
|
||||
return cancel_wakeup_output();
|
||||
|
||||
ACE_Message_Block* mblk;
|
||||
|
||||
@@ -387,7 +387,7 @@ int WorldSocket::handle_output_queue(GuardType& g)
|
||||
if (errno == EWOULDBLOCK || errno == EAGAIN)
|
||||
{
|
||||
msg_queue()->enqueue_head(mblk, (ACE_Time_Value*) &ACE_Time_Value::zero);
|
||||
return schedule_wakeup_output (g);
|
||||
return schedule_wakeup_output();
|
||||
}
|
||||
|
||||
mblk->release();
|
||||
@@ -404,23 +404,23 @@ int WorldSocket::handle_output_queue(GuardType& g)
|
||||
return -1;
|
||||
}
|
||||
|
||||
return schedule_wakeup_output (g);
|
||||
return schedule_wakeup_output();
|
||||
}
|
||||
else //now n == send_len
|
||||
{
|
||||
mblk->release();
|
||||
|
||||
return msg_queue()->is_empty() ? cancel_wakeup_output(g) : ACE_Event_Handler::WRITE_MASK;
|
||||
return msg_queue()->is_empty() ? cancel_wakeup_output() : ACE_Event_Handler::WRITE_MASK;
|
||||
}
|
||||
|
||||
ACE_NOTREACHED(return -1);
|
||||
return -1;
|
||||
}
|
||||
|
||||
int WorldSocket::handle_close(ACE_HANDLE h, ACE_Reactor_Mask)
|
||||
{
|
||||
// Critical section
|
||||
{
|
||||
ACE_GUARD_RETURN (LockType, Guard, m_OutBufferLock, -1);
|
||||
std::lock_guard<std::mutex> guard(m_OutBufferLock);
|
||||
|
||||
closing_ = true;
|
||||
|
||||
@@ -430,7 +430,7 @@ int WorldSocket::handle_close(ACE_HANDLE h, ACE_Reactor_Mask)
|
||||
|
||||
// Critical section
|
||||
{
|
||||
ACE_GUARD_RETURN (LockType, Guard, m_SessionLock, -1);
|
||||
std::lock_guard<decltype(m_SessionLock)> guard(m_SessionLock);
|
||||
|
||||
m_Session = nullptr;
|
||||
}
|
||||
@@ -448,7 +448,8 @@ int WorldSocket::Update(void)
|
||||
return 0;
|
||||
|
||||
{
|
||||
ACE_GUARD_RETURN (LockType, Guard, m_OutBufferLock, 0);
|
||||
std::lock_guard<std::mutex> guard(m_OutBufferLock);
|
||||
|
||||
if (m_OutBuffer->length() == 0 && msg_queue()->is_empty())
|
||||
return 0;
|
||||
}
|
||||
@@ -612,15 +613,13 @@ int WorldSocket::handle_input_missing_data(void)
|
||||
return size_t(n) == recv_size ? 1 : 2;
|
||||
}
|
||||
|
||||
int WorldSocket::cancel_wakeup_output(GuardType& g)
|
||||
int WorldSocket::cancel_wakeup_output()
|
||||
{
|
||||
if (!m_OutActive)
|
||||
return 0;
|
||||
|
||||
m_OutActive = false;
|
||||
|
||||
g.release();
|
||||
|
||||
if (reactor()->cancel_wakeup
|
||||
(this, ACE_Event_Handler::WRITE_MASK) == -1)
|
||||
{
|
||||
@@ -632,15 +631,13 @@ int WorldSocket::cancel_wakeup_output(GuardType& g)
|
||||
return 0;
|
||||
}
|
||||
|
||||
int WorldSocket::schedule_wakeup_output(GuardType& g)
|
||||
int WorldSocket::schedule_wakeup_output()
|
||||
{
|
||||
if (m_OutActive)
|
||||
return 0;
|
||||
|
||||
m_OutActive = true;
|
||||
|
||||
g.release();
|
||||
|
||||
if (reactor()->schedule_wakeup
|
||||
(this, ACE_Event_Handler::WRITE_MASK) == -1)
|
||||
{
|
||||
@@ -694,7 +691,7 @@ int WorldSocket::ProcessIncoming(WorldPacket* new_pct)
|
||||
return 0;
|
||||
default:
|
||||
{
|
||||
ACE_GUARD_RETURN (LockType, Guard, m_SessionLock, -1);
|
||||
std::lock_guard<std::mutex> guard(m_SessionLock);
|
||||
|
||||
if (m_Session != nullptr)
|
||||
{
|
||||
@@ -1050,7 +1047,7 @@ int WorldSocket::HandlePing(WorldPacket& recvPacket)
|
||||
|
||||
if (max_count && m_OverSpeedPings > max_count)
|
||||
{
|
||||
ACE_GUARD_RETURN(LockType, Guard, m_SessionLock, -1);
|
||||
std::lock_guard<std::mutex> guard(m_SessionLock);
|
||||
|
||||
if (m_Session && AccountMgr::IsPlayerAccount(m_Session->GetSecurity()))
|
||||
{
|
||||
@@ -1071,7 +1068,7 @@ int WorldSocket::HandlePing(WorldPacket& recvPacket)
|
||||
|
||||
// critical section
|
||||
{
|
||||
ACE_GUARD_RETURN(LockType, Guard, m_SessionLock, -1);
|
||||
std::lock_guard<std::mutex> guard(m_SessionLock);
|
||||
|
||||
if (m_Session)
|
||||
{
|
||||
|
||||
@@ -20,8 +20,8 @@
|
||||
#include <ace/SOCK_Stream.h>
|
||||
#include <ace/Svc_Handler.h>
|
||||
#include <ace/Synch_Traits.h>
|
||||
#include <ace/Thread_Mutex.h>
|
||||
#include <ace/Unbounded_Queue.h>
|
||||
#include <mutex>
|
||||
|
||||
#if !defined (ACE_LACKS_PRAGMA_ONCE)
|
||||
#pragma once
|
||||
@@ -78,10 +78,6 @@ public:
|
||||
|
||||
friend class WorldSocketMgr;
|
||||
|
||||
/// Mutex type used for various synchronizations.
|
||||
typedef ACE_Thread_Mutex LockType;
|
||||
typedef ACE_Guard<LockType> GuardType;
|
||||
|
||||
/// Check if socket is closed.
|
||||
bool IsClosed (void) const;
|
||||
|
||||
@@ -131,11 +127,11 @@ private:
|
||||
|
||||
/// Help functions to mark/unmark the socket for output.
|
||||
/// @param g the guard is for m_OutBufferLock, the function will release it
|
||||
int cancel_wakeup_output (GuardType& g);
|
||||
int schedule_wakeup_output (GuardType& g);
|
||||
int cancel_wakeup_output();
|
||||
int schedule_wakeup_output();
|
||||
|
||||
/// Drain the queue if its not empty.
|
||||
int handle_output_queue (GuardType& g);
|
||||
int handle_output_queue();
|
||||
|
||||
/// process one incoming packet.
|
||||
/// @param new_pct received packet, note that you need to delete it.
|
||||
@@ -161,7 +157,7 @@ private:
|
||||
AuthCrypt m_Crypt;
|
||||
|
||||
/// Mutex lock to protect m_Session
|
||||
LockType m_SessionLock;
|
||||
std::mutex m_SessionLock;
|
||||
|
||||
/// Session to which received packets are routed
|
||||
WorldSession* m_Session;
|
||||
@@ -178,7 +174,7 @@ private:
|
||||
ACE_Message_Block m_Header;
|
||||
|
||||
/// Mutex for protecting output related data.
|
||||
LockType m_OutBufferLock;
|
||||
std::mutex m_OutBufferLock;
|
||||
|
||||
/// Buffer used for writing output.
|
||||
ACE_Message_Block* m_OutBuffer;
|
||||
|
||||
@@ -92,7 +92,7 @@ public:
|
||||
|
||||
int AddSocket (WorldSocket* sock)
|
||||
{
|
||||
ACORE_GUARD(ACE_Thread_Mutex, m_NewSockets_Lock);
|
||||
std::lock_guard<std::mutex> guard(m_NewSockets_Lock);
|
||||
|
||||
++m_Connections;
|
||||
sock->AddReference();
|
||||
@@ -112,7 +112,7 @@ public:
|
||||
protected:
|
||||
void AddNewSockets()
|
||||
{
|
||||
ACORE_GUARD(ACE_Thread_Mutex, m_NewSockets_Lock);
|
||||
std::lock_guard<std::mutex> guard(m_NewSockets_Lock);
|
||||
|
||||
if (m_NewSockets.empty())
|
||||
return;
|
||||
@@ -194,7 +194,7 @@ private:
|
||||
SocketSet m_Sockets;
|
||||
|
||||
SocketSet m_NewSockets;
|
||||
ACE_Thread_Mutex m_NewSockets_Lock;
|
||||
std::mutex m_NewSockets_Lock;
|
||||
};
|
||||
|
||||
WorldSocketMgr::WorldSocketMgr() :
|
||||
|
||||
@@ -14,7 +14,6 @@
|
||||
#define __WORLDSOCKETMGR_H
|
||||
|
||||
#include "Common.h"
|
||||
#include <ace/Thread_Mutex.h>
|
||||
|
||||
class WorldSocket;
|
||||
class ReactorRunnable;
|
||||
|
||||
@@ -2251,7 +2251,7 @@ void World::Update(uint32 diff)
|
||||
// so we don't have to do it in every packet that modifies auctions
|
||||
AsyncAuctionListingMgr::SetAuctionListingAllowed(false);
|
||||
{
|
||||
ACORE_GUARD(ACE_Thread_Mutex, AsyncAuctionListingMgr::GetLock());
|
||||
std::lock_guard<std::mutex> guard(AsyncAuctionListingMgr::GetLock());
|
||||
|
||||
// pussywizard: handle auctions when the timer has passed
|
||||
if (m_timers[WUPDATE_AUCTIONS].Passed())
|
||||
|
||||
@@ -465,7 +465,7 @@ private:
|
||||
std::string _realmName;
|
||||
|
||||
// CLI command holder to be thread safe
|
||||
ACE_Based::LockedQueue<CliCommandHolder*, ACE_Thread_Mutex> cliCmdQueue;
|
||||
LockedQueue<CliCommandHolder*> cliCmdQueue;
|
||||
|
||||
// next daily quests and random bg reset time
|
||||
time_t m_NextDailyQuestReset;
|
||||
@@ -480,7 +480,7 @@ private:
|
||||
|
||||
// sessions that are added async
|
||||
void AddSession_(WorldSession* s);
|
||||
ACE_Based::LockedQueue<WorldSession*, ACE_Thread_Mutex> addSessQueue;
|
||||
LockedQueue<WorldSession*> addSessQueue;
|
||||
|
||||
// used versions
|
||||
std::string m_DBVersion;
|
||||
|
||||
Reference in New Issue
Block a user