Ditched ACE_Singleton in favor of C++11 like Singleton

This commit is contained in:
leak committed 2014-05-31 15:58:59 +02:00
1 parent f05d540658
commit bf6e58b8d4
3 files changed
+15 -10

No files matched your search

+3 -2
View File
@@ -152,8 +152,9 @@ int main(int argc, char** argv)
return 1;
// Get the list of realms for the server
sRealmList->Initialize(sConfigMgr->GetIntDefault("RealmsStateUpdateDelay", 20));
if (sRealmList->size() == 0)
sRealmList.Initialize(sConfigMgr->GetIntDefault("RealmsStateUpdateDelay", 20));
if (sRealmList.size() == 0)
{
TC_LOG_ERROR("server.authserver", "No valid realms specified.");
return 1;
+10 -6
View File
@@ -19,8 +19,6 @@
#ifndef _REALMLIST_H
#define _REALMLIST_H
#include <ace/Singleton.h>
#include <ace/Null_Mutex.h>
#include <ace/INET_Addr.h>
#include "Common.h"
@@ -59,8 +57,11 @@ class RealmList
public:
typedef std::map<std::string, Realm> RealmMap;
RealmList();
~RealmList() { }
static RealmList& instance()
{
static RealmList *instance = new RealmList();
return *instance;
}
void Initialize(uint32 updateInterval);
@@ -73,13 +74,16 @@ public:
uint32 size() const { return m_realms.size(); }
private:
RealmList();
void UpdateRealms(bool init = false);
void UpdateRealm(uint32 id, const std::string& name, ACE_INET_Addr const& address, ACE_INET_Addr const& localAddr, ACE_INET_Addr const& localSubmask, uint8 icon, RealmFlags flag, uint8 timezone, AccountTypes allowedSecurityLevel, float popu, uint32 build);
void UpdateRealm(uint32 id, const std::string& name, ACE_INET_Addr const& address, ACE_INET_Addr const& localAddr, ACE_INET_Addr const& localSubmask,
uint8 icon, RealmFlags flag, uint8 timezone, AccountTypes allowedSecurityLevel, float popu, uint32 build);
RealmMap m_realms;
uint32 m_UpdateInterval;
time_t m_NextUpdateTime;
};
#define sRealmList ACE_Singleton<RealmList, ACE_Null_Mutex>::instance()
#define sRealmList RealmList::instance()
#endif
+2 -2
View File
@@ -772,13 +772,13 @@ bool AuthSession::_HandleRealmList()
uint32 id = fields[0].GetUInt32();
// Update realm list if need
sRealmList->UpdateIfNeed();
sRealmList.UpdateIfNeed();
// Circle through realms in the RealmList and construct the return packet (including # of user characters in each realm)
ByteBuffer pkt;
size_t RealmListSize = 0;
for (RealmList::RealmMap::const_iterator i = sRealmList->begin(); i != sRealmList->end(); ++i)
for (RealmList::RealmMap::const_iterator i = sRealmList.begin(); i != sRealmList.end(); ++i)
{
const Realm &realm = i->second;
// don't work with realms which not compatible with the client