Get rid of Trinity Singleton and Threading patterns and replace them with ACE_Singletons and ACE_GUARD_x macro´s with ACE_Thread_Mutex´es respectively.

Also get rid of unused CountedReference class that used Trinity threading pattern.

--HG--
branch : trunk
This commit is contained in:
Machiavelli
2010-06-25 00:18:01 +02:00
parent a6b9e716a6
commit 0f7657b68c
109 changed files with 349 additions and 1221 deletions
+10 -11
View File
@@ -22,10 +22,9 @@
#define TRINITY_OBJECTACCESSOR_H
#include "Define.h"
#include "Singleton.h"
#include <ace/Singleton.h>
#include <ace/Thread_Mutex.h>
#include "UnorderedMap.h"
#include "ThreadingModel.h"
#include "UpdateData.h"
@@ -50,23 +49,22 @@ class HashMapHolder
typedef UNORDERED_MAP<uint64, T*> MapType;
typedef ACE_Thread_Mutex LockType;
typedef Trinity::GeneralLock<LockType> Guard;
static void Insert(T* o)
{
Guard guard(i_lock);
ACE_GUARD(LockType, Guard, i_lock);
m_objectMap[o->GetGUID()] = o;
}
static void Remove(T* o)
{
Guard guard(i_lock);
ACE_GUARD(LockType, Guard, i_lock);
m_objectMap.erase(o->GetGUID());
}
static T* Find(uint64 guid)
{
Guard guard(i_lock);
ACE_GUARD_RETURN(LockType, Guard, i_lock, NULL);
typename MapType::iterator itr = m_objectMap.find(guid);
return (itr != m_objectMap.end()) ? itr->second : NULL;
}
@@ -84,9 +82,9 @@ class HashMapHolder
static MapType m_objectMap;
};
class ObjectAccessor : public Trinity::Singleton<ObjectAccessor, Trinity::ClassLevelLockable<ObjectAccessor, ACE_Thread_Mutex> >
class ObjectAccessor
{
friend class Trinity::OperatorNew<ObjectAccessor>;
friend class ACE_Singleton<ObjectAccessor, ACE_Thread_Mutex>;
ObjectAccessor();
~ObjectAccessor();
ObjectAccessor(const ObjectAccessor&);
@@ -220,13 +218,13 @@ class ObjectAccessor : public Trinity::Singleton<ObjectAccessor, Trinity::ClassL
void AddUpdateObject(Object* obj)
{
Guard guard(i_updateGuard);
ACE_GUARD(LockType, Guard, i_updateGuard);
i_objects.insert(obj);
}
void RemoveUpdateObject(Object* obj)
{
Guard guard(i_updateGuard);
ACE_GUARD(LockType, Guard, i_updateGuard);
i_objects.erase(obj);
}
@@ -239,7 +237,6 @@ class ObjectAccessor : public Trinity::Singleton<ObjectAccessor, Trinity::ClassL
Corpse* ConvertCorpseForPlayer(uint64 player_guid, bool insignia = false);
typedef ACE_Thread_Mutex LockType;
typedef Trinity::GeneralLock<LockType> Guard;
private:
@@ -254,4 +251,6 @@ class ObjectAccessor : public Trinity::Singleton<ObjectAccessor, Trinity::ClassL
LockType i_updateGuard;
LockType i_corpseGuard;
};
#define sObjectAccessor (*ACE_Singleton<ObjectAccessor, ACE_Thread_Mutex>::instance())
#endif