Core: Converted (hopefully) all remaining singletons to use ACE_Singleton class

--HG--
branch : trunk
This commit is contained in:
Shauren
2010-12-22 20:52:47 +01:00
parent 7b4e1c6387
commit 0948fc5bbe
6 changed files with 28 additions and 57 deletions

View File

@@ -21,16 +21,6 @@
#include "ObjectMgr.h"
#include "DatabaseEnv.h"
SystemMgr::SystemMgr()
{
}
SystemMgr& SystemMgr::Instance()
{
static SystemMgr pSysMgr;
return pSysMgr;
}
void SystemMgr::LoadVersion()
{
//Get Version information

View File

@@ -4,6 +4,7 @@
#ifndef SC_SYSTEM_H
#define SC_SYSTEM_H
#include <ace/Singleton.h>
#define TEXT_SOURCE_RANGE -1000000 //the amount of entries each text source has available
@@ -51,13 +52,10 @@ struct StringTextData
class SystemMgr
{
public:
SystemMgr();
friend class ACE_Singleton<SystemMgr, ACE_Null_Mutex>;
SystemMgr() {}
~SystemMgr() {}
static SystemMgr& Instance();
public:
//Maps and lists
typedef UNORDERED_MAP<int32, StringTextData> TextDataMap;
typedef UNORDERED_MAP<uint32, std::vector<ScriptPointMove> > PointMoveMap;
@@ -97,6 +95,6 @@ class SystemMgr
PointMoveMap m_mPointMoveMap; //coordinates for waypoints
};
#define sScriptSystemMgr SystemMgr::Instance()
#define sScriptSystemMgr (*ACE_Singleton<SystemMgr, ACE_Null_Mutex>::instance())
#endif

View File

@@ -363,10 +363,3 @@ WorldSocketMgr::OnSocketOpen (WorldSocket* sock)
return m_NetThreads[min].AddSocket (sock);
}
WorldSocketMgr*
WorldSocketMgr::Instance()
{
return ACE_Singleton<WorldSocketMgr,ACE_Thread_Mutex>::instance();
}

View File

@@ -37,42 +37,38 @@ class ACE_Event_Handler;
class WorldSocketMgr
{
public:
friend class WorldSocket;
friend class ACE_Singleton<WorldSocketMgr,ACE_Thread_Mutex>;
friend class WorldSocket;
friend class ACE_Singleton<WorldSocketMgr, ACE_Thread_Mutex>;
/// Start network, listen at address:port .
int StartNetwork (ACE_UINT16 port, const char* address);
/// Start network, listen at address:port .
int StartNetwork(ACE_UINT16 port, const char* address);
/// Stops all network threads, It will wait for all running threads .
void StopNetwork();
/// Stops all network threads, It will wait for all running threads .
void StopNetwork();
/// Wait untill all network threads have "joined" .
void Wait();
/// Make this class singleton .
static WorldSocketMgr* Instance();
/// Wait untill all network threads have "joined" .
void Wait();
private:
int OnSocketOpen(WorldSocket* sock);
int OnSocketOpen(WorldSocket* sock);
int StartReactiveIO(ACE_UINT16 port, const char* address);
int StartReactiveIO(ACE_UINT16 port, const char* address);
private:
WorldSocketMgr();
virtual ~WorldSocketMgr();
WorldSocketMgr();
virtual ~WorldSocketMgr();
ReactorRunnable* m_NetThreads;
size_t m_NetThreadsCount;
ReactorRunnable* m_NetThreads;
size_t m_NetThreadsCount;
int m_SockOutKBuff;
int m_SockOutUBuff;
bool m_UseNoDelay;
int m_SockOutKBuff;
int m_SockOutUBuff;
bool m_UseNoDelay;
ACE_Event_Handler* m_Acceptor;
ACE_Event_Handler* m_Acceptor;
};
#define sWorldSocketMgr WorldSocketMgr::Instance()
#define sWorldSocketMgr ACE_Singleton<WorldSocketMgr,ACE_Thread_Mutex>::instance()
#endif
/// @}

View File

@@ -256,12 +256,6 @@ SpellMgr::~SpellMgr()
{
}
SpellMgr& SpellMgr::Instance()
{
static SpellMgr spellMgr;
return spellMgr;
}
bool SpellMgr::IsSrcTargetSpell(SpellEntry const *spellInfo) const
{
for (uint8 i = 0; i< MAX_SPELL_EFFECTS; ++i)

View File

@@ -21,6 +21,7 @@
// For static or at-server-startup loaded spell data
// For more high level function for sSpellStore data
#include <ace/Singleton.h>
#include "SharedDefines.h"
#include "SpellAuraDefines.h"
@@ -914,8 +915,7 @@ inline bool IsProfessionOrRidingSkill(uint32 skill)
class SpellMgr
{
// Constructors
public:
friend class ACE_Singleton<SpellMgr, ACE_Null_Mutex>;
SpellMgr();
~SpellMgr();
@@ -1387,7 +1387,6 @@ class SpellMgr
// Modifiers
public:
static SpellMgr& Instance();
// Loading data at server startup
void LoadSpellRanks();
@@ -1443,5 +1442,6 @@ class SpellMgr
SpellDifficultySearcherMap mSpellDifficultySearcherMap;
};
#define sSpellMgr SpellMgr::Instance()
#define sSpellMgr (*ACE_Singleton<SpellMgr, ACE_Null_Mutex>::instance())
#endif