mirror of
https://github.com/mod-playerbots/azerothcore-wotlk.git
synced 2026-01-13 09:17:18 +00:00
feat(Core/Threading): replace ace threading (#4821)
This commit is contained in:
@@ -80,7 +80,7 @@ namespace MMAP
|
||||
return uint32(x << 16 | y);
|
||||
}
|
||||
|
||||
ACE_RW_Thread_Mutex& MMapManager::GetMMapLock(uint32 mapId)
|
||||
std::shared_mutex& MMapManager::GetMMapLock(uint32 mapId)
|
||||
{
|
||||
Map* map = sMapMgr->FindBaseMap(mapId);
|
||||
if (!map)
|
||||
@@ -88,12 +88,13 @@ namespace MMAP
|
||||
sLog->outMisc("ZOMG! MoveMaps: BaseMap not found!");
|
||||
return this->MMapLock;
|
||||
}
|
||||
|
||||
return map->GetMMapLock();
|
||||
}
|
||||
|
||||
bool MMapManager::loadMap(uint32 mapId, int32 x, int32 y)
|
||||
{
|
||||
ACORE_WRITE_GUARD(ACE_RW_Thread_Mutex, MMapManagerLock);
|
||||
std::unique_lock<std::shared_mutex> guard(MMapManagerLock);
|
||||
|
||||
// make sure the mmap is loaded and ready to load tiles
|
||||
if (!loadMapData(mapId))
|
||||
@@ -161,7 +162,7 @@ namespace MMAP
|
||||
|
||||
dtStatus stat;
|
||||
{
|
||||
ACORE_WRITE_GUARD(ACE_RW_Thread_Mutex, GetMMapLock(mapId));
|
||||
std::unique_lock<std::shared_mutex> guard(GetMMapLock(mapId));
|
||||
stat = mmap->navMesh->addTile(data, fileHeader.size, DT_TILE_FREE_DATA, 0, &tileRef);
|
||||
}
|
||||
|
||||
@@ -188,7 +189,7 @@ namespace MMAP
|
||||
|
||||
bool MMapManager::unloadMap(uint32 mapId, int32 x, int32 y)
|
||||
{
|
||||
ACORE_WRITE_GUARD(ACE_RW_Thread_Mutex, MMapManagerLock);
|
||||
std::unique_lock<std::shared_mutex> guard(MMapManagerLock);
|
||||
|
||||
// check if we have this map loaded
|
||||
if (loadedMMaps.find(mapId) == loadedMMaps.end())
|
||||
@@ -217,7 +218,7 @@ namespace MMAP
|
||||
|
||||
dtStatus status;
|
||||
{
|
||||
ACORE_WRITE_GUARD(ACE_RW_Thread_Mutex, GetMMapLock(mapId));
|
||||
std::unique_lock<std::shared_mutex> guard(GetMMapLock(mapId));
|
||||
status = mmap->navMesh->removeTile(tileRef, nullptr, nullptr);
|
||||
}
|
||||
|
||||
@@ -245,7 +246,7 @@ namespace MMAP
|
||||
|
||||
bool MMapManager::unloadMap(uint32 mapId)
|
||||
{
|
||||
ACORE_WRITE_GUARD(ACE_RW_Thread_Mutex, MMapManagerLock);
|
||||
std::unique_lock<std::shared_mutex> guard(MMapManagerLock);
|
||||
|
||||
if (loadedMMaps.find(mapId) == loadedMMaps.end())
|
||||
{
|
||||
@@ -265,7 +266,7 @@ namespace MMAP
|
||||
|
||||
dtStatus status;
|
||||
{
|
||||
ACORE_WRITE_GUARD(ACE_RW_Thread_Mutex, GetMMapLock(mapId));
|
||||
std::unique_lock<std::shared_mutex> guard(GetMMapLock(mapId));
|
||||
status = mmap->navMesh->removeTile(i->second, nullptr, nullptr);
|
||||
}
|
||||
|
||||
@@ -291,7 +292,7 @@ namespace MMAP
|
||||
|
||||
bool MMapManager::unloadMapInstance(uint32 mapId, uint32 instanceId)
|
||||
{
|
||||
ACORE_WRITE_GUARD(ACE_RW_Thread_Mutex, MMapManagerLock);
|
||||
std::unique_lock<std::shared_mutex> guard(MMapManagerLock);
|
||||
|
||||
// check if we have this map loaded
|
||||
if (loadedMMaps.find(mapId) == loadedMMaps.end())
|
||||
@@ -325,9 +326,6 @@ namespace MMAP
|
||||
|
||||
dtNavMesh const* MMapManager::GetNavMesh(uint32 mapId)
|
||||
{
|
||||
// pussywizard: moved to calling function
|
||||
//ACORE_READ_GUARD(ACE_RW_Thread_Mutex, MMapManagerLock);
|
||||
|
||||
if (loadedMMaps.find(mapId) == loadedMMaps.end())
|
||||
return nullptr;
|
||||
|
||||
@@ -336,9 +334,6 @@ namespace MMAP
|
||||
|
||||
dtNavMeshQuery const* MMapManager::GetNavMeshQuery(uint32 mapId, uint32 instanceId)
|
||||
{
|
||||
// pussywizard: moved to calling function
|
||||
//ACORE_READ_GUARD(ACE_RW_Thread_Mutex, MMapManagerLock);
|
||||
|
||||
if (loadedMMaps.find(mapId) == loadedMMaps.end())
|
||||
return nullptr;
|
||||
|
||||
@@ -346,7 +341,7 @@ namespace MMAP
|
||||
if (mmap->navMeshQueries.find(instanceId) == mmap->navMeshQueries.end())
|
||||
{
|
||||
// pussywizard: different instances of the same map shouldn't access this simultaneously
|
||||
ACORE_WRITE_GUARD(ACE_RW_Thread_Mutex, GetMMapLock(mapId));
|
||||
std::unique_lock<std::shared_mutex> guard(GetMMapLock(mapId));
|
||||
// check again after acquiring mutex
|
||||
if (mmap->navMeshQueries.find(instanceId) == mmap->navMeshQueries.end())
|
||||
{
|
||||
|
||||
@@ -12,6 +12,7 @@
|
||||
#include "DetourExtended.h"
|
||||
#include "World.h"
|
||||
#include <unordered_map>
|
||||
#include <shared_mutex>
|
||||
|
||||
// memory management
|
||||
inline void* dtCustomAlloc(size_t size, dtAllocHint /*hint*/)
|
||||
@@ -72,9 +73,9 @@ namespace MMAP
|
||||
uint32 getLoadedTilesCount() const { return loadedTiles; }
|
||||
uint32 getLoadedMapsCount() const { return loadedMMaps.size(); }
|
||||
|
||||
ACE_RW_Thread_Mutex& GetMMapLock(uint32 mapId);
|
||||
ACE_RW_Thread_Mutex& GetMMapGeneralLock() { return MMapLock; } // pussywizard: in case a per-map mutex can't be found, should never happen
|
||||
ACE_RW_Thread_Mutex& GetManagerLock() { return MMapManagerLock; }
|
||||
std::shared_mutex& GetMMapLock(uint32 mapId);
|
||||
std::shared_mutex& GetMMapGeneralLock() { return MMapLock; } // pussywizard: in case a per-map mutex can't be found, should never happen
|
||||
std::shared_mutex& GetManagerLock() { return MMapManagerLock; }
|
||||
private:
|
||||
bool loadMapData(uint32 mapId);
|
||||
uint32 packTileID(int32 x, int32 y);
|
||||
@@ -82,9 +83,9 @@ namespace MMAP
|
||||
MMapDataSet loadedMMaps;
|
||||
uint32 loadedTiles;
|
||||
|
||||
ACE_RW_Thread_Mutex MMapManagerLock;
|
||||
ACE_RW_Thread_Mutex MMapLock; // pussywizard: in case a per-map mutex can't be found, should never happen
|
||||
std::shared_mutex MMapManagerLock;
|
||||
std::shared_mutex MMapLock; // pussywizard: in case a per-map mutex can't be found, should never happen
|
||||
};
|
||||
}
|
||||
|
||||
#endif
|
||||
#endif
|
||||
|
||||
@@ -262,7 +262,7 @@ namespace VMAP
|
||||
WorldModel* VMapManager2::acquireModelInstance(const std::string& basepath, const std::string& filename)
|
||||
{
|
||||
//! Critical section, thread safe access to iLoadedModelFiles
|
||||
ACORE_GUARD(ACE_Thread_Mutex, LoadedModelFilesLock);
|
||||
std::lock_guard<std::mutex> guard(LoadedModelFilesLock);
|
||||
|
||||
ModelFileMap::iterator model = iLoadedModelFiles.find(filename);
|
||||
if (model == iLoadedModelFiles.end())
|
||||
@@ -287,7 +287,7 @@ namespace VMAP
|
||||
void VMapManager2::releaseModelInstance(const std::string& filename)
|
||||
{
|
||||
//! Critical section, thread safe access to iLoadedModelFiles
|
||||
ACORE_GUARD(ACE_Thread_Mutex, LoadedModelFilesLock);
|
||||
std::lock_guard<std::mutex> guard(LoadedModelFilesLock);
|
||||
ModelFileMap::iterator model = iLoadedModelFiles.find(filename);
|
||||
if (model == iLoadedModelFiles.end())
|
||||
{
|
||||
|
||||
@@ -20,7 +20,7 @@
|
||||
|
||||
#include "IVMapManager.h"
|
||||
#include "Define.h"
|
||||
#include <ace/Thread_Mutex.h>
|
||||
#include <mutex>
|
||||
#include <unordered_map>
|
||||
|
||||
//===========================================================
|
||||
@@ -72,7 +72,7 @@ namespace VMAP
|
||||
ModelFileMap iLoadedModelFiles;
|
||||
InstanceTreeMap iInstanceMapTrees;
|
||||
// Mutex for iLoadedModelFiles
|
||||
ACE_Thread_Mutex LoadedModelFilesLock;
|
||||
std::mutex LoadedModelFilesLock;
|
||||
|
||||
bool _loadMap(uint32 mapId, const std::string& basePath, uint32 tileX, uint32 tileY);
|
||||
/* void _unloadMap(uint32 pMapId, uint32 x, uint32 y); */
|
||||
|
||||
@@ -78,9 +78,6 @@
|
||||
|
||||
#include "Threading/LockedQueue.h"
|
||||
#include "Threading/Threading.h"
|
||||
|
||||
#include <ace/RW_Thread_Mutex.h>
|
||||
#include <ace/Thread_Mutex.h>
|
||||
#include <ace/Stack_Trace.h>
|
||||
|
||||
#if AC_PLATFORM == AC_PLATFORM_WINDOWS
|
||||
@@ -124,8 +121,6 @@ inline float finiteAlways(float f) { return isfinite(f) ? f : 0.0f; }
|
||||
|
||||
inline bool myisfinite(float f) { return isfinite(f) && !isnan(f); }
|
||||
|
||||
#define atol(a) strtoul( a, nullptr, 10)
|
||||
|
||||
#define STRINGIZE(a) #a
|
||||
|
||||
#define MAX_NETCLIENT_PACKET_SIZE (32767 - 1) // Client hardcap: int16 with trailing zero space otherwise crash on memory free
|
||||
@@ -187,22 +182,6 @@ typedef std::vector<std::string> StringVector;
|
||||
|
||||
#define MAX_QUERY_LEN 32*1024
|
||||
|
||||
#define ACORE_GUARD(MUTEX, LOCK) \
|
||||
ACE_Guard< MUTEX > ACORE_GUARD_OBJECT (LOCK); \
|
||||
if (ACORE_GUARD_OBJECT.locked() == 0) ASSERT(false);
|
||||
|
||||
//! For proper implementation of multiple-read, single-write pattern, use
|
||||
//! ACE_RW_Mutex as underlying @MUTEX
|
||||
# define ACORE_WRITE_GUARD(MUTEX, LOCK) \
|
||||
ACE_Write_Guard< MUTEX > ACORE_GUARD_OBJECT (LOCK); \
|
||||
if (ACORE_GUARD_OBJECT.locked() == 0) ASSERT(false);
|
||||
|
||||
//! For proper implementation of multiple-read, single-write pattern, use
|
||||
//! ACE_RW_Mutex as underlying @MUTEX
|
||||
# define ACORE_READ_GUARD(MUTEX, LOCK) \
|
||||
ACE_Read_Guard< MUTEX > ACORE_GUARD_OBJECT (LOCK); \
|
||||
if (ACORE_GUARD_OBJECT.locked() == 0) ASSERT(false);
|
||||
|
||||
namespace acore
|
||||
{
|
||||
template<class ArgumentType, class ResultType>
|
||||
|
||||
@@ -18,7 +18,7 @@
|
||||
#include "QueryHolder.h"
|
||||
#include "AdhocStatement.h"
|
||||
#include "StringFormat.h"
|
||||
#include <ace/Thread_Mutex.h>
|
||||
#include <mutex>
|
||||
|
||||
class PingOperation : public SQLOperation
|
||||
{
|
||||
|
||||
@@ -90,13 +90,13 @@ protected:
|
||||
{
|
||||
/// Tries to acquire lock. If lock is acquired by another thread
|
||||
/// the calling parent will just try another connection
|
||||
return m_Mutex.tryacquire() != -1;
|
||||
return m_Mutex.try_lock();
|
||||
}
|
||||
|
||||
void Unlock()
|
||||
{
|
||||
/// Called by parent databasepool. Will let other threads access this connection
|
||||
m_Mutex.release();
|
||||
m_Mutex.unlock();
|
||||
}
|
||||
|
||||
MYSQL* GetHandle() { return m_Mysql; }
|
||||
@@ -120,7 +120,7 @@ private:
|
||||
MYSQL* m_Mysql; //! MySQL Handle.
|
||||
MySQLConnectionInfo& m_connectionInfo; //! Connection info (used for logging)
|
||||
ConnectionFlags m_connectionFlags; //! Connection flags (for preparing relevant statements)
|
||||
ACE_Thread_Mutex m_Mutex;
|
||||
std::mutex m_Mutex;
|
||||
|
||||
MySQLConnection(MySQLConnection const& right) = delete;
|
||||
MySQLConnection& operator=(MySQLConnection const& right) = delete;
|
||||
|
||||
@@ -7,10 +7,9 @@
|
||||
#ifndef QUERYRESULT_H
|
||||
#define QUERYRESULT_H
|
||||
|
||||
#include <ace/Thread_Mutex.h>
|
||||
|
||||
#include "Errors.h"
|
||||
#include "Field.h"
|
||||
#include <mutex>
|
||||
|
||||
#ifdef _WIN32
|
||||
#include <winsock2.h>
|
||||
|
||||
@@ -7,137 +7,134 @@
|
||||
#ifndef LOCKEDQUEUE_H
|
||||
#define LOCKEDQUEUE_H
|
||||
|
||||
#include "Debugging/Errors.h"
|
||||
#include <ace/Guard_T.h>
|
||||
#include <ace/Thread_Mutex.h>
|
||||
#include <cassert>
|
||||
#include <deque>
|
||||
#include <mutex>
|
||||
|
||||
namespace ACE_Based
|
||||
template <class T, typename StorageType = std::deque<T> >
|
||||
class LockedQueue
|
||||
{
|
||||
template <class T, class LockType, typename StorageType = std::deque<T>>
|
||||
class LockedQueue
|
||||
//! Lock access to the queue.
|
||||
std::mutex _lock;
|
||||
|
||||
//! Storage backing the queue.
|
||||
StorageType _queue;
|
||||
|
||||
//! Cancellation flag.
|
||||
volatile bool _canceled;
|
||||
|
||||
public:
|
||||
|
||||
//! Create a LockedQueue.
|
||||
LockedQueue()
|
||||
: _canceled(false)
|
||||
{
|
||||
//! Lock access to the queue.
|
||||
LockType _lock;
|
||||
}
|
||||
|
||||
//! Storage backing the queue.
|
||||
StorageType _queue;
|
||||
//! Destroy a LockedQueue.
|
||||
virtual ~LockedQueue()
|
||||
{
|
||||
}
|
||||
|
||||
//! Cancellation flag.
|
||||
volatile bool _canceled{false};
|
||||
//! Adds an item to the queue.
|
||||
void add(const T& item)
|
||||
{
|
||||
lock();
|
||||
|
||||
public:
|
||||
//! Create a LockedQueue.
|
||||
LockedQueue()
|
||||
_queue.push_back(item);
|
||||
|
||||
{
|
||||
}
|
||||
unlock();
|
||||
}
|
||||
|
||||
//! Destroy a LockedQueue.
|
||||
virtual ~LockedQueue() = default;
|
||||
//! Adds items back to front of the queue
|
||||
template<class Iterator>
|
||||
void readd(Iterator begin, Iterator end)
|
||||
{
|
||||
std::lock_guard<std::mutex> lock(_lock);
|
||||
_queue.insert(_queue.begin(), begin, end);
|
||||
}
|
||||
|
||||
//! Adds an item to the queue.
|
||||
void add(const T& item)
|
||||
{
|
||||
lock();
|
||||
//! Gets the next result in the queue, if any.
|
||||
bool next(T& result)
|
||||
{
|
||||
std::lock_guard<std::mutex> lock(_lock);
|
||||
|
||||
//ASSERT(!this->_canceled);
|
||||
// throw Cancellation_Exception();
|
||||
if (_queue.empty())
|
||||
return false;
|
||||
|
||||
_queue.push_back(item);
|
||||
result = _queue.front();
|
||||
_queue.pop_front();
|
||||
|
||||
return true;
|
||||
}
|
||||
|
||||
template<class Checker>
|
||||
bool next(T& result, Checker& check)
|
||||
{
|
||||
std::lock_guard<std::mutex> lock(_lock);
|
||||
|
||||
if (_queue.empty())
|
||||
return false;
|
||||
|
||||
result = _queue.front();
|
||||
if (!check.Process(result))
|
||||
return false;
|
||||
|
||||
_queue.pop_front();
|
||||
return true;
|
||||
}
|
||||
|
||||
//! Peeks at the top of the queue. Check if the queue is empty before calling! Remember to unlock after use if autoUnlock == false.
|
||||
T& peek(bool autoUnlock = false)
|
||||
{
|
||||
lock();
|
||||
|
||||
T& result = _queue.front();
|
||||
|
||||
if (autoUnlock)
|
||||
unlock();
|
||||
}
|
||||
|
||||
//! Gets the next result in the queue, if any.
|
||||
bool next(T& result)
|
||||
{
|
||||
// ACE_Guard<LockType> g(this->_lock);
|
||||
ACE_GUARD_RETURN (LockType, g, this->_lock, false);
|
||||
return result;
|
||||
}
|
||||
|
||||
if (_queue.empty())
|
||||
return false;
|
||||
//! Cancels the queue.
|
||||
void cancel()
|
||||
{
|
||||
std::lock_guard<std::mutex> lock(_lock);
|
||||
|
||||
//ASSERT (!_queue.empty() || !this->_canceled);
|
||||
// throw Cancellation_Exception();
|
||||
result = _queue.front();
|
||||
_queue.pop_front();
|
||||
_canceled = true;
|
||||
}
|
||||
|
||||
return true;
|
||||
}
|
||||
//! Checks if the queue is cancelled.
|
||||
bool cancelled()
|
||||
{
|
||||
std::lock_guard<std::mutex> lock(_lock);
|
||||
return _canceled;
|
||||
}
|
||||
|
||||
template<class Checker>
|
||||
bool next(T& result, Checker& check)
|
||||
{
|
||||
ACE_Guard<LockType> g(this->_lock);
|
||||
//! Locks the queue for access.
|
||||
void lock()
|
||||
{
|
||||
this->_lock.lock();
|
||||
}
|
||||
|
||||
if (_queue.empty())
|
||||
return false;
|
||||
//! Unlocks the queue.
|
||||
void unlock()
|
||||
{
|
||||
this->_lock.unlock();
|
||||
}
|
||||
|
||||
result = _queue.front();
|
||||
if (!check.Process(result))
|
||||
return false;
|
||||
///! Calls pop_front of the queue
|
||||
void pop_front()
|
||||
{
|
||||
std::lock_guard<std::mutex> lock(_lock);
|
||||
_queue.pop_front();
|
||||
}
|
||||
|
||||
_queue.pop_front();
|
||||
return true;
|
||||
}
|
||||
|
||||
//! Peeks at the top of the queue. Check if the queue is empty before calling! Remember to unlock after use if autoUnlock == false.
|
||||
T& peek(bool autoUnlock = false)
|
||||
{
|
||||
lock();
|
||||
|
||||
T& result = _queue.front();
|
||||
|
||||
if (autoUnlock)
|
||||
unlock();
|
||||
|
||||
return result;
|
||||
}
|
||||
|
||||
//! Cancels the queue.
|
||||
void cancel()
|
||||
{
|
||||
lock();
|
||||
|
||||
_canceled = true;
|
||||
|
||||
unlock();
|
||||
}
|
||||
|
||||
//! Checks if the queue is cancelled.
|
||||
bool cancelled()
|
||||
{
|
||||
ACE_Guard<LockType> g(this->_lock);
|
||||
return _canceled;
|
||||
}
|
||||
|
||||
//! Locks the queue for access.
|
||||
void lock()
|
||||
{
|
||||
this->_lock.acquire();
|
||||
}
|
||||
|
||||
//! Unlocks the queue.
|
||||
void unlock()
|
||||
{
|
||||
this->_lock.release();
|
||||
}
|
||||
|
||||
///! Calls pop_front of the queue
|
||||
void pop_front()
|
||||
{
|
||||
ACE_GUARD (LockType, g, this->_lock);
|
||||
_queue.pop_front();
|
||||
}
|
||||
|
||||
///! Checks if we're empty or not with locks held
|
||||
bool empty()
|
||||
{
|
||||
ACE_GUARD_RETURN (LockType, g, this->_lock, false);
|
||||
return _queue.empty();
|
||||
}
|
||||
};
|
||||
}
|
||||
///! Checks if we're empty or not with locks held
|
||||
bool empty()
|
||||
{
|
||||
std::lock_guard<std::mutex> lock(_lock);
|
||||
return _queue.empty();
|
||||
}
|
||||
};
|
||||
#endif
|
||||
|
||||
@@ -273,7 +273,7 @@ void AuthSocket::OnRead()
|
||||
|
||||
std::map<std::string, uint32> LastLoginAttemptTimeForIP;
|
||||
uint32 LastLoginAttemptCleanTime = 0;
|
||||
ACE_Thread_Mutex LastLoginAttemptMutex;
|
||||
std::mutex LastLoginAttemptMutex;
|
||||
|
||||
// Logon Challenge command handler
|
||||
bool AuthSocket::_HandleLogonChallenge()
|
||||
@@ -289,7 +289,7 @@ bool AuthSocket::_HandleLogonChallenge()
|
||||
|
||||
// pussywizard: logon flood protection:
|
||||
{
|
||||
ACORE_GUARD(ACE_Thread_Mutex, LastLoginAttemptMutex);
|
||||
std::lock_guard<std::mutex> guard(LastLoginAttemptMutex);
|
||||
std::string ipaddr = socket().getRemoteAddress();
|
||||
uint32 currTime = time(nullptr);
|
||||
std::map<std::string, uint32>::iterator itr = LastLoginAttemptTimeForIP.find(ipaddr);
|
||||
|
||||
@@ -52,7 +52,7 @@ public:
|
||||
bool _HandleXferAccept();
|
||||
|
||||
FILE* pPatch;
|
||||
ACE_Thread_Mutex patcherLock;
|
||||
std::mutex patcherLock;
|
||||
|
||||
private:
|
||||
RealmSocket& socket_;
|
||||
|
||||
@@ -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;
|
||||
|
||||
@@ -109,7 +109,8 @@ public:
|
||||
bool first = true;
|
||||
bool footer = false;
|
||||
|
||||
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)
|
||||
{
|
||||
|
||||
@@ -2254,7 +2254,7 @@ public:
|
||||
else
|
||||
{
|
||||
// pussywizard: notify all online GMs
|
||||
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)
|
||||
if (itr->second->GetSession()->GetSecurity())
|
||||
|
||||
@@ -284,7 +284,7 @@ public:
|
||||
stmt->setUInt16(0, uint16(atLogin));
|
||||
CharacterDatabase.Execute(stmt);
|
||||
|
||||
ACORE_READ_GUARD(HashMapHolder<Player>::LockType, *HashMapHolder<Player>::GetLock());
|
||||
std::shared_lock<std::shared_mutex> lock(*HashMapHolder<Player>::GetLock());
|
||||
HashMapHolder<Player>::MapType const& plist = sObjectAccessor->GetPlayers();
|
||||
for (HashMapHolder<Player>::MapType::const_iterator itr = plist.begin(); itr != plist.end(); ++itr)
|
||||
itr->second->SetAtLoginFlag(atLogin);
|
||||
|
||||
@@ -74,7 +74,7 @@ void OutdoorPvPSI::HandlePlayerLeaveZone(Player* player, uint32 zone)
|
||||
|
||||
bool OutdoorPvPSI::HandleAreaTrigger(Player* player, uint32 trigger)
|
||||
{
|
||||
ACORE_GUARD(ACE_Thread_Mutex, sOutdoorPvPMgr->_lock);
|
||||
std::lock_guard<std::mutex> guard(sOutdoorPvPMgr->_lock);
|
||||
|
||||
switch (trigger)
|
||||
{
|
||||
|
||||
@@ -97,10 +97,10 @@ void AuctionListingRunnable::run()
|
||||
|
||||
if (AsyncAuctionListingMgr::GetTempList().size() || AsyncAuctionListingMgr::GetList().size())
|
||||
{
|
||||
ACORE_GUARD(ACE_Thread_Mutex, AsyncAuctionListingMgr::GetLock());
|
||||
std::lock_guard<std::mutex> guard(AsyncAuctionListingMgr::GetLock());
|
||||
|
||||
{
|
||||
ACORE_GUARD(ACE_Thread_Mutex, AsyncAuctionListingMgr::GetTempLock());
|
||||
std::lock_guard<std::mutex> guard(AsyncAuctionListingMgr::GetTempLock());
|
||||
for (std::list<AuctionListItemsDelayEvent>::iterator itr = AsyncAuctionListingMgr::GetTempList().begin(); itr != AsyncAuctionListingMgr::GetTempList().end(); ++itr)
|
||||
AsyncAuctionListingMgr::GetList().push_back( (*itr) );
|
||||
AsyncAuctionListingMgr::GetTempList().clear();
|
||||
|
||||
Reference in New Issue
Block a user