Use TRINITY_GUARD to replace ACE_GUARD. ASSERT(false) if failed to acquire the lock.
This commit is contained in:
@@ -2677,7 +2677,7 @@ bool ChatHandler::HandleResetAllCommand(const char * args)
|
|||||||
|
|
||||||
CharacterDatabase.PExecute("UPDATE characters SET at_login = at_login | '%u' WHERE (at_login & '%u') = '0'", atLogin, atLogin);
|
CharacterDatabase.PExecute("UPDATE characters SET at_login = at_login | '%u' WHERE (at_login & '%u') = '0'", atLogin, atLogin);
|
||||||
|
|
||||||
ACE_READ_GUARD_RETURN(HashMapHolder<Player>::LockType, guard, *HashMapHolder<Player>::GetLock(), true);
|
TRINITY_READ_GUARD(HashMapHolder<Player>::LockType, *HashMapHolder<Player>::GetLock());
|
||||||
HashMapHolder<Player>::MapType const& plist = sObjectAccessor->GetPlayers();
|
HashMapHolder<Player>::MapType const& plist = sObjectAccessor->GetPlayers();
|
||||||
for (HashMapHolder<Player>::MapType::const_iterator itr = plist.begin(); itr != plist.end(); ++itr)
|
for (HashMapHolder<Player>::MapType::const_iterator itr = plist.begin(); itr != plist.end(); ++itr)
|
||||||
itr->second->SetAtLoginFlag(atLogin);
|
itr->second->SetAtLoginFlag(atLogin);
|
||||||
|
|||||||
@@ -165,7 +165,7 @@ Unit* ObjectAccessor::FindUnit(uint64 guid)
|
|||||||
|
|
||||||
Player* ObjectAccessor::FindPlayerByName(const char* name)
|
Player* ObjectAccessor::FindPlayerByName(const char* name)
|
||||||
{
|
{
|
||||||
ACE_READ_GUARD_RETURN(HashMapHolder<Player>::LockType, g, *HashMapHolder<Player>::GetLock(), NULL);
|
TRINITY_READ_GUARD(HashMapHolder<Player>::LockType, *HashMapHolder<Player>::GetLock());
|
||||||
HashMapHolder<Player>::MapType const& m = GetPlayers();
|
HashMapHolder<Player>::MapType const& m = GetPlayers();
|
||||||
for (HashMapHolder<Player>::MapType::const_iterator iter = m.begin(); iter != m.end(); ++iter)
|
for (HashMapHolder<Player>::MapType::const_iterator iter = m.begin(); iter != m.end(); ++iter)
|
||||||
if (iter->second->IsInWorld() && strcmp(name, iter->second->GetName()) == 0)
|
if (iter->second->IsInWorld() && strcmp(name, iter->second->GetName()) == 0)
|
||||||
@@ -176,7 +176,7 @@ Player* ObjectAccessor::FindPlayerByName(const char* name)
|
|||||||
|
|
||||||
void ObjectAccessor::SaveAllPlayers()
|
void ObjectAccessor::SaveAllPlayers()
|
||||||
{
|
{
|
||||||
ACE_READ_GUARD(HashMapHolder<Player>::LockType, g, *HashMapHolder<Player>::GetLock());
|
TRINITY_READ_GUARD(HashMapHolder<Player>::LockType, *HashMapHolder<Player>::GetLock());
|
||||||
HashMapHolder<Player>::MapType const& m = GetPlayers();
|
HashMapHolder<Player>::MapType const& m = GetPlayers();
|
||||||
for (HashMapHolder<Player>::MapType::const_iterator itr = m.begin(); itr != m.end(); ++itr)
|
for (HashMapHolder<Player>::MapType::const_iterator itr = m.begin(); itr != m.end(); ++itr)
|
||||||
itr->second->SaveToDB();
|
itr->second->SaveToDB();
|
||||||
|
|||||||
@@ -52,19 +52,19 @@ class HashMapHolder
|
|||||||
|
|
||||||
static void Insert(T* o)
|
static void Insert(T* o)
|
||||||
{
|
{
|
||||||
ACE_WRITE_GUARD(LockType, Guard, i_lock);
|
TRINITY_WRITE_GUARD(LockType, i_lock);
|
||||||
m_objectMap[o->GetGUID()] = o;
|
m_objectMap[o->GetGUID()] = o;
|
||||||
}
|
}
|
||||||
|
|
||||||
static void Remove(T* o)
|
static void Remove(T* o)
|
||||||
{
|
{
|
||||||
ACE_WRITE_GUARD(LockType, Guard, i_lock);
|
TRINITY_WRITE_GUARD(LockType, i_lock);
|
||||||
m_objectMap.erase(o->GetGUID());
|
m_objectMap.erase(o->GetGUID());
|
||||||
}
|
}
|
||||||
|
|
||||||
static T* Find(uint64 guid)
|
static T* Find(uint64 guid)
|
||||||
{
|
{
|
||||||
ACE_READ_GUARD_RETURN(LockType, Guard, i_lock, NULL);
|
TRINITY_READ_GUARD(LockType, i_lock);
|
||||||
typename MapType::iterator itr = m_objectMap.find(guid);
|
typename MapType::iterator itr = m_objectMap.find(guid);
|
||||||
return (itr != m_objectMap.end()) ? itr->second : NULL;
|
return (itr != m_objectMap.end()) ? itr->second : NULL;
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -239,7 +239,7 @@ void WorldSession::HandleWhoOpcode(WorldPacket & recv_data)
|
|||||||
data << uint32(matchcount); // placeholder, count of players matching criteria
|
data << uint32(matchcount); // placeholder, count of players matching criteria
|
||||||
data << uint32(displaycount); // placeholder, count of players displayed
|
data << uint32(displaycount); // placeholder, count of players displayed
|
||||||
|
|
||||||
ACE_READ_GUARD(HashMapHolder<Player>::LockType, g, *HashMapHolder<Player>::GetLock());
|
TRINITY_READ_GUARD(HashMapHolder<Player>::LockType, *HashMapHolder<Player>::GetLock());
|
||||||
HashMapHolder<Player>::MapType const& m = sObjectAccessor->GetPlayers();
|
HashMapHolder<Player>::MapType const& m = sObjectAccessor->GetPlayers();
|
||||||
for (HashMapHolder<Player>::MapType::const_iterator itr = m.begin(); itr != m.end(); ++itr)
|
for (HashMapHolder<Player>::MapType::const_iterator itr = m.begin(); itr != m.end(); ++itr)
|
||||||
{
|
{
|
||||||
|
|||||||
@@ -117,7 +117,7 @@ public:
|
|||||||
bool first = true;
|
bool first = true;
|
||||||
bool footer = false;
|
bool footer = false;
|
||||||
|
|
||||||
ACE_READ_GUARD_RETURN(HashMapHolder<Player>::LockType, guard, *HashMapHolder<Player>::GetLock(), true);
|
TRINITY_READ_GUARD(HashMapHolder<Player>::LockType, *HashMapHolder<Player>::GetLock());
|
||||||
HashMapHolder<Player>::MapType const& m = sObjectAccessor->GetPlayers();
|
HashMapHolder<Player>::MapType const& m = sObjectAccessor->GetPlayers();
|
||||||
for (HashMapHolder<Player>::MapType::const_iterator itr = m.begin(); itr != m.end(); ++itr)
|
for (HashMapHolder<Player>::MapType::const_iterator itr = m.begin(); itr != m.end(); ++itr)
|
||||||
{
|
{
|
||||||
|
|||||||
@@ -203,4 +203,17 @@ typedef std::vector<std::string> StringVector;
|
|||||||
#endif
|
#endif
|
||||||
|
|
||||||
#define MAX_QUERY_LEN 32*1024
|
#define MAX_QUERY_LEN 32*1024
|
||||||
|
|
||||||
|
#define TRINITY_GUARD(MUTEX, LOCK) \
|
||||||
|
ACE_Guard< MUTEX > TRINITY_GUARD_OBJECT (LOCK); \
|
||||||
|
if (TRINITY_GUARD_OBJECT.locked() == 0) ASSERT(false);
|
||||||
|
|
||||||
|
# define TRINITY_WRITE_GUARD(MUTEX, LOCK) \
|
||||||
|
ACE_Write_Guard< MUTEX > TRINITY_GUARD_OBJECT (LOCK); \
|
||||||
|
if (TRINITY_GUARD_OBJECT.locked() == 0) ASSERT(false);
|
||||||
|
|
||||||
|
# define TRINITY_READ_GUARD(MUTEX, LOCK) \
|
||||||
|
ACE_Read_Guard< MUTEX > TRINITY_GUARD_OBJECT (LOCK); \
|
||||||
|
if (TRINITY_GUARD_OBJECT.locked() == 0) ASSERT(false);
|
||||||
|
|
||||||
#endif
|
#endif
|
||||||
|
|||||||
Reference in New Issue
Block a user