Replaced all remaining ACE based Singletons

Replaced ACE base AutoPtr class with shared_ptr
Note: worldserver currently broken due to MapUpdater threading failure (ACE ofc, what else could it be)
This commit is contained in:
leak
2014-07-01 00:54:09 +02:00
parent d39a013b6b
commit 029bad6698
61 changed files with 347 additions and 243 deletions
-1
View File
@@ -178,7 +178,6 @@ int main(int argc, char** argv)
SetProcessPriority();
_dbPingInterval = sConfigMgr->GetIntDefault("MaxPingTime", 30);
_dbPingTimer.expires_from_now(boost::posix_time::seconds(_dbPingInterval));
@@ -26,8 +26,6 @@
#include "ModelInstance.h"
#include "WorldModel.h"
#include <G3D/Vector3.h>
#include <ace/Null_Mutex.h>
#include <ace/Singleton.h>
#include "DisableMgr.h"
#include "DBCStores.h"
#include "Log.h"
@@ -1396,11 +1396,17 @@ typedef std::unordered_map<uint32, ObjectGuidList*> ObjectListMap;
class SmartWaypointMgr
{
friend class ACE_Singleton<SmartWaypointMgr, ACE_Null_Mutex>;
SmartWaypointMgr() { }
public:
private:
SmartWaypointMgr() { }
~SmartWaypointMgr();
public:
static SmartWaypointMgr* instance()
{
static SmartWaypointMgr* instance = new SmartWaypointMgr();
return instance;
}
void LoadFromDB();
WPPath* GetPath(uint32 id)
@@ -1426,11 +1432,17 @@ typedef std::pair<CacheSpellContainer::const_iterator, CacheSpellContainer::cons
class SmartAIMgr
{
friend class ACE_Singleton<SmartAIMgr, ACE_Null_Mutex>;
SmartAIMgr() { }
public:
private:
SmartAIMgr() { }
~SmartAIMgr() { }
public:
static SmartAIMgr* instance()
{
static SmartAIMgr* instance = new SmartAIMgr();
return instance;
}
void LoadSmartAIFromDB();
SmartAIEventList GetScript(int32 entry, SmartScriptType type)
@@ -1598,6 +1610,6 @@ class SmartAIMgr
CacheSpellContainer KillCreditSpellStore;
};
#define sSmartScriptMgr ACE_Singleton<SmartAIMgr, ACE_Null_Mutex>::instance()
#define sSmartWaypointMgr ACE_Singleton<SmartWaypointMgr, ACE_Null_Mutex>::instance()
#define sSmartScriptMgr SmartAIMgr::instance()
#define sSmartWaypointMgr SmartWaypointMgr::instance()
#endif
+7 -4
View File
@@ -20,7 +20,6 @@
#define _ACCMGR_H
#include "RBAC.h"
#include <ace/Singleton.h>
enum AccountOpResult
{
@@ -51,13 +50,17 @@ typedef std::map<uint8, rbac::RBACPermissionContainer> RBACDefaultPermissionsCon
class AccountMgr
{
friend class ACE_Singleton<AccountMgr, ACE_Null_Mutex>;
private:
AccountMgr();
~AccountMgr();
public:
static AccountMgr* instance()
{
static AccountMgr* instance = new AccountMgr();
return instance;
}
AccountOpResult CreateAccount(std::string username, std::string password, std::string email);
static AccountOpResult DeleteAccount(uint32 accountId);
static AccountOpResult ChangeUsername(uint32 accountId, std::string newUsername, std::string newPassword);
@@ -95,5 +98,5 @@ class AccountMgr
rbac::RBACDefaultPermissionsContainer _defaultPermissions;
};
#define sAccountMgr ACE_Singleton<AccountMgr, ACE_Null_Mutex>::instance()
#define sAccountMgr AccountMgr::instance()
#endif
@@ -23,7 +23,6 @@
#include <string>
#include "Common.h"
#include <ace/Singleton.h>
#include "DatabaseEnv.h"
#include "DBCEnums.h"
#include "DBCStores.h"
@@ -305,11 +304,16 @@ class AchievementMgr
class AchievementGlobalMgr
{
friend class ACE_Singleton<AchievementGlobalMgr, ACE_Null_Mutex>;
AchievementGlobalMgr() { }
~AchievementGlobalMgr() { }
public:
static AchievementGlobalMgr* instance()
{
static AchievementGlobalMgr* instance = new AchievementGlobalMgr();
return instance;
}
AchievementCriteriaEntryList const& GetAchievementCriteriaByType(AchievementCriteriaTypes type) const
{
return m_AchievementCriteriasByType[type];
@@ -389,6 +393,6 @@ class AchievementGlobalMgr
AchievementRewardLocales m_achievementRewardLocales;
};
#define sAchievementMgr ACE_Singleton<AchievementGlobalMgr, ACE_Null_Mutex>::instance()
#define sAchievementMgr AchievementGlobalMgr::instance()
#endif
@@ -19,8 +19,6 @@
#ifndef _AUCTION_HOUSE_MGR_H
#define _AUCTION_HOUSE_MGR_H
#include <ace/Singleton.h>
#include "Common.h"
#include "DatabaseEnv.h"
#include "DBCStructure.h"
@@ -137,13 +135,16 @@ class AuctionHouseObject
class AuctionHouseMgr
{
friend class ACE_Singleton<AuctionHouseMgr, ACE_Null_Mutex>;
private:
AuctionHouseMgr();
~AuctionHouseMgr();
public:
static AuctionHouseMgr* instance()
{
static AuctionHouseMgr* instance = new AuctionHouseMgr();
return instance;
}
typedef std::unordered_map<uint32, Item*> ItemMap;
@@ -193,6 +194,6 @@ class AuctionHouseMgr
ItemMap mAitems;
};
#define sAuctionMgr ACE_Singleton<AuctionHouseMgr, ACE_Null_Mutex>::instance()
#define sAuctionMgr AuctionHouseMgr::instance()
#endif
+10 -7
View File
@@ -19,7 +19,6 @@
#define BATTLEFIELD_MGR_H_
#include "Battlefield.h"
#include <ace/Singleton.h>
class Player;
class ZoneScript;
@@ -28,11 +27,12 @@ class ZoneScript;
class BattlefieldMgr
{
public:
// ctor
BattlefieldMgr();
// dtor
~BattlefieldMgr();
static BattlefieldMgr* instance()
{
static BattlefieldMgr* instance = new BattlefieldMgr();
return instance;
}
// create battlefield events
void InitBattlefield();
@@ -52,6 +52,9 @@ class BattlefieldMgr
void Update(uint32 diff);
private:
BattlefieldMgr();
~BattlefieldMgr();
typedef std::vector<Battlefield*> BattlefieldSet;
typedef std::map<uint32 /*zoneId*/, Battlefield*> BattlefieldMap;
// contains all initiated battlefield events
@@ -64,6 +67,6 @@ class BattlefieldMgr
uint32 _updateTimer;
};
#define sBattlefieldMgr ACE_Singleton<BattlefieldMgr, ACE_Null_Mutex>::instance()
#define sBattlefieldMgr BattlefieldMgr::instance()
#endif // BATTLEFIELD_MGR_H_
@@ -20,7 +20,6 @@
#define TRINITYCORE_ARENATEAM_H
#include "QueryResult.h"
#include <ace/Singleton.h>
#include <list>
#include <map>
+8 -2
View File
@@ -22,11 +22,17 @@
class ArenaTeamMgr
{
friend class ACE_Singleton<ArenaTeamMgr, ACE_Null_Mutex>;
private:
ArenaTeamMgr();
~ArenaTeamMgr();
public:
static ArenaTeamMgr* instance()
{
static ArenaTeamMgr* instance = new ArenaTeamMgr();
return instance;
}
typedef std::unordered_map<uint32, ArenaTeam*> ArenaTeamContainer;
ArenaTeam* GetArenaTeamById(uint32 arenaTeamId) const;
@@ -50,6 +56,6 @@ protected:
ArenaTeamContainer ArenaTeamStore;
};
#define sArenaTeamMgr ACE_Singleton<ArenaTeamMgr, ACE_Null_Mutex>::instance()
#define sArenaTeamMgr ArenaTeamMgr::instance()
#endif
@@ -23,7 +23,6 @@
#include "DBCEnums.h"
#include "Battleground.h"
#include "BattlegroundQueue.h"
#include <ace/Singleton.h>
typedef std::map<uint32, Battleground*> BattlegroundContainer;
typedef std::set<uint32> BattlegroundClientIdsContainer;
@@ -64,13 +63,17 @@ struct BattlegroundData
class BattlegroundMgr
{
friend class ACE_Singleton<BattlegroundMgr, ACE_Null_Mutex>;
private:
BattlegroundMgr();
~BattlegroundMgr();
public:
static BattlegroundMgr* instance()
{
static BattlegroundMgr* instance = new BattlegroundMgr();
return instance;
}
void Update(uint32 diff);
/* Packet Building */
@@ -158,5 +161,5 @@ class BattlegroundMgr
BattleMastersMap mBattleMastersMap;
};
#define sBattlegroundMgr ACE_Singleton<BattlegroundMgr, ACE_Null_Mutex>::instance()
#define sBattlegroundMgr BattlegroundMgr::instance()
#endif
+7 -4
View File
@@ -18,7 +18,6 @@
#ifndef TRINITY_CALENDARMGR_H
#define TRINITY_CALENDARMGR_H
#include <ace/Singleton.h>
#include "Common.h"
#include "DatabaseEnv.h"
#include "WorldPacket.h"
@@ -268,8 +267,6 @@ typedef std::map<uint64 /* eventId */, CalendarInviteStore > CalendarEventInvite
class CalendarMgr
{
friend class ACE_Singleton<CalendarMgr, ACE_Null_Mutex>;
private:
CalendarMgr();
~CalendarMgr();
@@ -283,6 +280,12 @@ class CalendarMgr
uint64 _maxInviteId;
public:
static CalendarMgr* instance()
{
static CalendarMgr* instance = new CalendarMgr();
return instance;
}
void LoadFromDB();
CalendarEvent* GetEvent(uint64 eventId) const;
@@ -329,6 +332,6 @@ class CalendarMgr
void SendPacketToAllEventRelatives(WorldPacket packet, CalendarEvent const& calendarEvent);
};
#define sCalendarMgr ACE_Singleton<CalendarMgr, ACE_Null_Mutex>::instance()
#define sCalendarMgr CalendarMgr::instance()
#endif
+3 -3
View File
@@ -29,13 +29,13 @@ ChannelMgr::~ChannelMgr()
ChannelMgr* ChannelMgr::forTeam(uint32 team)
{
if (sWorld->getBoolConfig(CONFIG_ALLOW_TWO_SIDE_INTERACTION_CHANNEL))
return ACE_Singleton<AllianceChannelMgr, ACE_Null_Mutex>::instance(); // cross-faction
return AllianceChannelMgr::instance(); // cross-faction
if (team == ALLIANCE)
return ACE_Singleton<AllianceChannelMgr, ACE_Null_Mutex>::instance();
return AllianceChannelMgr::instance();
if (team == HORDE)
return ACE_Singleton<HordeChannelMgr, ACE_Null_Mutex>::instance();
return HordeChannelMgr::instance();
return NULL;
}
+9 -5
View File
@@ -20,7 +20,6 @@
#include "Common.h"
#include "Channel.h"
#include <ace/Singleton.h>
#include <map>
#include <string>
@@ -31,12 +30,17 @@ class ChannelMgr
{
typedef std::map<std::wstring, Channel*> ChannelMap;
public:
ChannelMgr() : team(0)
{ }
protected:
ChannelMgr() : team(0) { }
~ChannelMgr();
public:
static ChannelMgr* instance()
{
static ChannelMgr* instance = new ChannelMgr();
return instance;
}
static ChannelMgr * forTeam(uint32 team);
void setTeam(uint32 newTeam) { team = newTeam; }
+8 -4
View File
@@ -21,7 +21,6 @@
#include "Define.h"
#include "Errors.h"
#include <ace/Singleton.h>
#include <list>
#include <map>
@@ -223,13 +222,18 @@ typedef std::map<uint32, ConditionList> ConditionReferenceContainer;//only used
class ConditionMgr
{
friend class ACE_Singleton<ConditionMgr, ACE_Null_Mutex>;
private:
ConditionMgr();
~ConditionMgr();
public:
static ConditionMgr* instance()
{
static ConditionMgr* instance = new ConditionMgr();
return instance;
}
void LoadConditions(bool isReload = false);
bool isConditionTypeValid(Condition* cond);
ConditionList GetConditionReferences(uint32 refId);
@@ -265,6 +269,6 @@ class ConditionMgr
SmartEventConditionContainer SmartEventConditionStore;
};
#define sConditionMgr ACE_Singleton<ConditionMgr, ACE_Null_Mutex>::instance()
#define sConditionMgr ConditionMgr::instance()
#endif
+5 -5
View File
@@ -535,7 +535,7 @@ struct AreaTableEntry
{
if (mapid == 609)
return true;
return (flags & AREA_FLAG_SANCTUARY);
return (flags & AREA_FLAG_SANCTUARY) != 0;
}
};
@@ -1367,7 +1367,7 @@ struct MapEntry
return MapID == 0 || MapID == 1 || MapID == 530 || MapID == 571;
}
bool IsDynamicDifficultyMap() const { return Flags & MAP_FLAG_DYNAMIC_DIFFICULTY; }
bool IsDynamicDifficultyMap() const { return (Flags & MAP_FLAG_DYNAMIC_DIFFICULTY) != 0; }
};
struct MapDifficultyEntry
@@ -2047,12 +2047,12 @@ struct VehicleSeatEntry
uint32 m_flagsB; // 45
// 46-57 added in 3.1, floats mostly
bool CanEnterOrExit() const { return m_flags & VEHICLE_SEAT_FLAG_CAN_ENTER_OR_EXIT; }
bool CanSwitchFromSeat() const { return m_flags & VEHICLE_SEAT_FLAG_CAN_SWITCH; }
bool CanEnterOrExit() const { return (m_flags & VEHICLE_SEAT_FLAG_CAN_ENTER_OR_EXIT) != 0; }
bool CanSwitchFromSeat() const { return (m_flags & VEHICLE_SEAT_FLAG_CAN_SWITCH) != 0; }
bool IsUsableByOverride() const { return (m_flags & (VEHICLE_SEAT_FLAG_UNCONTROLLED | VEHICLE_SEAT_FLAG_UNK18)
|| (m_flagsB & (VEHICLE_SEAT_FLAG_B_USABLE_FORCED | VEHICLE_SEAT_FLAG_B_USABLE_FORCED_2 |
VEHICLE_SEAT_FLAG_B_USABLE_FORCED_3 | VEHICLE_SEAT_FLAG_B_USABLE_FORCED_4))); }
bool IsEjectable() const { return m_flagsB & VEHICLE_SEAT_FLAG_B_EJECTABLE; }
bool IsEjectable() const { return (m_flagsB & VEHICLE_SEAT_FLAG_B_EJECTABLE) != 0; }
};
struct WMOAreaTableEntry
+7 -4
View File
@@ -18,7 +18,6 @@
#ifndef _LFGMGR_H
#define _LFGMGR_H
#include <ace/Singleton.h>
#include "DBCStructure.h"
#include "Field.h"
#include "LFG.h"
@@ -292,13 +291,17 @@ struct LFGDungeonData
class LFGMgr
{
friend class ACE_Singleton<LFGMgr, ACE_Null_Mutex>;
private:
LFGMgr();
~LFGMgr();
public:
static LFGMgr* instance()
{
static LFGMgr* instance = new LFGMgr();
return instance;
}
// Functions used outside lfg namespace
void Update(uint32 diff);
@@ -466,5 +469,5 @@ class LFGMgr
} // namespace lfg
#define sLFGMgr ACE_Singleton<lfg::LFGMgr, ACE_Null_Mutex>::instance()
#define sLFGMgr lfg::LFGMgr::instance()
#endif
@@ -40,10 +40,17 @@ typedef std::unordered_map<uint32/*memberDBGUID*/, FormationInfo*> CreatureGro
class FormationMgr
{
friend class ACE_Singleton<FormationMgr, ACE_Null_Mutex>;
public:
private:
FormationMgr() { }
~FormationMgr();
public:
static FormationMgr* instance()
{
static FormationMgr* instance = new FormationMgr();
return instance;
}
void AddCreatureToGroup(uint32 group_id, Creature* creature);
void RemoveCreatureFromGroup(CreatureGroup* group, Creature* creature);
void LoadCreatureFormations();
@@ -78,6 +85,6 @@ class CreatureGroup
void MemberAttackStart(Creature* member, Unit* target);
};
#define sFormationMgr ACE_Singleton<FormationMgr, ACE_Null_Mutex>::instance()
#define sFormationMgr FormationMgr::instance()
#endif
+2 -2
View File
@@ -310,7 +310,7 @@ void Item::UpdateDuration(Player* owner, uint32 diff)
void Item::SaveToDB(SQLTransaction& trans)
{
bool isInTransaction = !(trans.null());
bool isInTransaction = !trans;
if (!isInTransaction)
trans = CharacterDatabase.BeginTransaction();
@@ -1129,7 +1129,7 @@ void Item::SaveRefundDataToDB()
void Item::DeleteRefundDataFromDB(SQLTransaction* trans)
{
if (trans && !trans->null())
if (trans)
{
PreparedStatement* stmt = CharacterDatabase.GetPreparedStatement(CHAR_DEL_ITEM_REFUND_INSTANCE);
stmt->setUInt32(0, GetGUIDLow());
+3 -3
View File
@@ -7326,7 +7326,7 @@ void Player::ModifyHonorPoints(int32 value, SQLTransaction* trans /*=NULL*/)
newValue = 0;
SetHonorPoints(uint32(newValue));
if (trans && !trans->null())
if (trans && !trans)
{
PreparedStatement* stmt = CharacterDatabase.GetPreparedStatement(CHAR_UPD_CHAR_HONOR_POINTS);
stmt->setUInt32(0, newValue);
@@ -7342,7 +7342,7 @@ void Player::ModifyArenaPoints(int32 value, SQLTransaction* trans /*=NULL*/)
newValue = 0;
SetArenaPoints(uint32(newValue));
if (trans && !trans->null())
if (trans && !trans)
{
PreparedStatement* stmt = CharacterDatabase.GetPreparedStatement(CHAR_UPD_CHAR_ARENA_POINTS);
stmt->setUInt32(0, newValue);
@@ -19769,7 +19769,7 @@ void Player::_SaveMail(SQLTransaction& trans)
void Player::_SaveQuestStatus(SQLTransaction& trans)
{
bool isTransaction = !trans.null();
bool isTransaction = !trans;
if (!isTransaction)
trans = CharacterDatabase.BeginTransaction();
+7 -4
View File
@@ -19,7 +19,6 @@
#ifndef __TRINITY_SOCIALMGR_H
#define __TRINITY_SOCIALMGR_H
#include <ace/Singleton.h>
#include "DatabaseEnv.h"
#include "Common.h"
@@ -123,13 +122,17 @@ class PlayerSocial
class SocialMgr
{
friend class ACE_Singleton<SocialMgr, ACE_Null_Mutex>;
private:
SocialMgr();
~SocialMgr();
public:
static SocialMgr* instance()
{
static SocialMgr* instance = new SocialMgr();
return instance;
}
// Misc
void RemovePlayerSocial(uint32 guid) { m_socialMap.erase(guid); }
@@ -144,5 +147,5 @@ class SocialMgr
SocialMap m_socialMap;
};
#define sSocialMgr ACE_Singleton<SocialMgr, ACE_Null_Mutex>::instance()
#define sSocialMgr SocialMgr::instance()
#endif
+7 -4
View File
@@ -22,7 +22,6 @@
#include "Common.h"
#include "SharedDefines.h"
#include "Define.h"
#include <ace/Singleton.h>
#define max_ge_check_delay DAY // 1 day in seconds
@@ -95,13 +94,17 @@ class Quest;
class GameEventMgr
{
friend class ACE_Singleton<GameEventMgr, ACE_Null_Mutex>;
private:
GameEventMgr();
~GameEventMgr() { };
public:
static GameEventMgr* instance()
{
static GameEventMgr* instance = new GameEventMgr();
return instance;
}
typedef std::set<uint16> ActiveEvents;
typedef std::vector<GameEventData> GameEventDataMap;
ActiveEvents const& GetActiveEventList() const { return m_ActiveEvents; }
@@ -180,7 +183,7 @@ class GameEventMgr
GameEventGuidMap mGameEventGameobjectGuids;
};
#define sGameEventMgr ACE_Singleton<GameEventMgr, ACE_Null_Mutex>::instance()
#define sGameEventMgr GameEventMgr::instance()
bool IsHolidayActive(HolidayIds id);
bool IsEventActive(uint16 event_id);
+7 -3
View File
@@ -35,7 +35,6 @@
#include "Map.h"
#include "ObjectAccessor.h"
#include "ObjectDefines.h"
#include <ace/Singleton.h>
#include "VehicleDefines.h"
#include <string>
#include <map>
@@ -687,13 +686,18 @@ class PlayerDumpReader;
class ObjectMgr
{
friend class PlayerDumpReader;
friend class ACE_Singleton<ObjectMgr, ACE_Null_Mutex>;
private:
ObjectMgr();
~ObjectMgr();
public:
static ObjectMgr* instance()
{
static ObjectMgr* instance = new ObjectMgr();
return instance;
}
typedef std::unordered_map<uint32, Item*> ItemMap;
typedef std::unordered_map<uint32, Quest*> QuestMap;
@@ -1442,6 +1446,6 @@ class ObjectMgr
std::set<uint32> _transportMaps; // Helper container storing map ids that are for transports only, loaded from gameobject_template
};
#define sObjectMgr ACE_Singleton<ObjectMgr, ACE_Null_Mutex>::instance()
#define sObjectMgr ObjectMgr::instance()
#endif
+7 -2
View File
@@ -22,12 +22,17 @@
class GroupMgr
{
friend class ACE_Singleton<GroupMgr, ACE_Null_Mutex>;
private:
GroupMgr();
~GroupMgr();
public:
static GroupMgr* instance()
{
static GroupMgr* instance = new GroupMgr();
return instance;
}
typedef std::map<uint32, Group*> GroupContainer;
typedef std::vector<Group*> GroupDbContainer;
@@ -53,6 +58,6 @@ protected:
GroupDbContainer GroupDbStore;
};
#define sGroupMgr ACE_Singleton<GroupMgr, ACE_Null_Mutex>::instance()
#define sGroupMgr GroupMgr::instance()
#endif
+7 -3
View File
@@ -22,13 +22,17 @@
class GuildMgr
{
friend class ACE_Singleton<GuildMgr, ACE_Null_Mutex>;
private:
GuildMgr();
~GuildMgr();
public:
static GuildMgr* instance()
{
static GuildMgr* instance = new GuildMgr();
return instance;
}
Guild* GetGuildByLeader(uint64 guid) const;
Guild* GetGuildById(uint32 guildId) const;
Guild* GetGuildByName(std::string const& guildName) const;
@@ -48,6 +52,6 @@ protected:
GuildContainer GuildStore;
};
#define sGuildMgr ACE_Singleton<GuildMgr, ACE_Null_Mutex>::instance()
#define sGuildMgr GuildMgr::instance()
#endif
@@ -22,10 +22,6 @@
#include "Opcodes.h"
#include "Log.h"
AddonHandler::AddonHandler() { }
AddonHandler::~AddonHandler() { }
bool AddonHandler::BuildAddonPacket(WorldPacket* source, WorldPacket* target)
{
ByteBuffer AddOnPacked;
+11 -8
View File
@@ -21,20 +21,23 @@
#include "Common.h"
#include "Config.h"
#include <ace/Singleton.h>
#include "WorldPacket.h"
class AddonHandler
{
/* Construction */
friend class ACE_Singleton<AddonHandler, ACE_Null_Mutex>;
AddonHandler();
public:
~AddonHandler();
//build addon packet
static AddonHandler* instance()
{
static AddonHandler* instance = new AddonHandler();
return instance;
}
bool BuildAddonPacket(WorldPacket* Source, WorldPacket* Target);
private:
AddonHandler() { }
~AddonHandler() { }
};
#define sAddOnHandler ACE_Singleton<AddonHandler, ACE_Null_Mutex>::instance()
#define sAddOnHandler AddonHandler::instance()
#endif
+7 -7
View File
@@ -24,18 +24,18 @@
#include "GridStates.h"
#include "MapUpdater.h"
#include <ace/Singleton.h>
#include <ace/Thread_Mutex.h>
class Transport;
struct TransportCreatureProto;
class MapManager
{
friend class ACE_Singleton<MapManager, ACE_Thread_Mutex>;
public:
static MapManager* instance()
{
static MapManager* instance = new MapManager();
return instance;
}
Map* CreateBaseMap(uint32 mapId);
Map* FindBaseNonInstanceMap(uint32 mapId) const;
Map* CreateMap(uint32 mapId, Player* player);
@@ -150,5 +150,5 @@ class MapManager
uint32 _nextInstanceId;
MapUpdater m_updater;
};
#define sMapMgr ACE_Singleton<MapManager, ACE_Thread_Mutex>::instance()
#define sMapMgr MapManager::instance()
#endif
+7 -3
View File
@@ -18,7 +18,6 @@
#ifndef TRANSPORTMGR_H
#define TRANSPORTMGR_H
#include <ace/Singleton.h>
#include <G3D/Quat.h>
#include "Spline.h"
#include "DBCStores.h"
@@ -96,10 +95,15 @@ typedef std::map<uint32, TransportAnimation> TransportAnimationContainer;
class TransportMgr
{
friend class ACE_Singleton<TransportMgr, ACE_Thread_Mutex>;
friend void LoadDBCStores(std::string const&);
public:
static TransportMgr* instance()
{
static TransportMgr* instance = new TransportMgr();
return instance;
}
void Unload();
void LoadTransportTemplates();
@@ -155,6 +159,6 @@ class TransportMgr
TransportAnimationContainer _transportAnimations;
};
#define sTransportMgr ACE_Singleton<TransportMgr, ACE_Thread_Mutex>::instance()
#define sTransportMgr TransportMgr::instance()
#endif // TRANSPORTMGR_H
@@ -20,7 +20,6 @@
#define TRINITY_MOVEMENTGENERATOR_H
#include "Define.h"
#include <ace/Singleton.h>
#include "ObjectRegistry.h"
#include "FactoryHolder.h"
#include "Common.h"
@@ -19,8 +19,6 @@
#ifndef TRINITY_WAYPOINTMANAGER_H
#define TRINITY_WAYPOINTMANAGER_H
#include <ace/Singleton.h>
#include <ace/Null_Mutex.h>
#include <vector>
struct WaypointData
@@ -38,9 +36,13 @@ typedef std::unordered_map<uint32, WaypointPath> WaypointPathContainer;
class WaypointMgr
{
friend class ACE_Singleton<WaypointMgr, ACE_Null_Mutex>;
public:
static WaypointMgr* instance()
{
static WaypointMgr* instance = new WaypointMgr();
return instance;
}
// Attempts to reload a single path from database
void ReloadPath(uint32 id);
@@ -58,13 +60,12 @@ class WaypointMgr
}
private:
// Only allow instantiation from ACE_Singleton
WaypointMgr();
~WaypointMgr();
WaypointPathContainer _waypointStore;
};
#define sWaypointMgr ACE_Singleton<WaypointMgr, ACE_Null_Mutex>::instance()
#define sWaypointMgr WaypointMgr::instance()
#endif
+7 -4
View File
@@ -21,7 +21,6 @@
#define OUTDOORPVP_OBJECTIVE_UPDATE_INTERVAL 1000
#include "OutdoorPvP.h"
#include <ace/Singleton.h>
class Player;
class GameObject;
@@ -38,13 +37,17 @@ struct OutdoorPvPData
// class to handle player enter / leave / areatrigger / GO use events
class OutdoorPvPMgr
{
friend class ACE_Singleton<OutdoorPvPMgr, ACE_Null_Mutex>;
private:
OutdoorPvPMgr();
~OutdoorPvPMgr() { };
public:
static OutdoorPvPMgr* instance()
{
static OutdoorPvPMgr* instance = new OutdoorPvPMgr();
return instance;
}
// create outdoor pvp events
void InitOutdoorPvP();
@@ -101,6 +104,6 @@ class OutdoorPvPMgr
uint32 m_UpdateTimer;
};
#define sOutdoorPvPMgr ACE_Singleton<OutdoorPvPMgr, ACE_Null_Mutex>::instance()
#define sOutdoorPvPMgr OutdoorPvPMgr::instance()
#endif /*OUTDOOR_PVP_MGR_H_*/
+7 -4
View File
@@ -20,7 +20,6 @@
#define TRINITY_POOLHANDLER_H
#include "Define.h"
#include <ace/Singleton.h>
#include "Creature.h"
#include "GameObject.h"
#include "QuestDef.h"
@@ -104,13 +103,17 @@ typedef std::pair<PooledQuestRelation::iterator, PooledQuestRelation::iterator>
class PoolMgr
{
friend class ACE_Singleton<PoolMgr, ACE_Null_Mutex>;
private:
PoolMgr();
~PoolMgr() { };
public:
static PoolMgr* instance()
{
static PoolMgr* instance = new PoolMgr();
return instance;
}
void LoadFromDB();
void LoadQuestPools();
void SaveQuestsToDB();
@@ -164,7 +167,7 @@ class PoolMgr
ActivePoolData mSpawnedData;
};
#define sPoolMgr ACE_Singleton<PoolMgr, ACE_Null_Mutex>::instance()
#define sPoolMgr PoolMgr::instance()
// Method that tell if the creature is part of a pool and return the pool id if yes
template<>
+6 -4
View File
@@ -20,7 +20,6 @@
#define SC_SCRIPTMGR_H
#include "Common.h"
#include <ace/Singleton.h>
#include <ace/Atomic_Op.h>
#include "DBCStores.h"
@@ -869,20 +868,23 @@ class GroupScript : public ScriptObject
};
// Placed here due to ScriptRegistry::AddScript dependency.
#define sScriptMgr ACE_Singleton<ScriptMgr, ACE_Null_Mutex>::instance()
#define sScriptMgr ScriptMgr::instance()
// Manages registration, loading, and execution of scripts.
class ScriptMgr
{
friend class ACE_Singleton<ScriptMgr, ACE_Null_Mutex>;
friend class ScriptObject;
private:
ScriptMgr();
virtual ~ScriptMgr();
public: /* Initialization */
static ScriptMgr* instance()
{
static ScriptMgr* instance = new ScriptMgr();
return instance;
}
void Initialize();
void LoadDatabase();
+8 -3
View File
@@ -6,7 +6,6 @@
#define SC_SYSTEM_H
#include "ScriptMgr.h"
#include <ace/Singleton.h>
#define TEXT_SOURCE_RANGE -1000000 //the amount of entries each text source has available
@@ -48,11 +47,17 @@ typedef std::vector<ScriptPointMove> ScriptPointVector;
class SystemMgr
{
friend class ACE_Singleton<SystemMgr, ACE_Null_Mutex>;
private:
SystemMgr() { }
~SystemMgr() { }
public:
static SystemMgr* instance()
{
static SystemMgr* instance = new SystemMgr();
return instance;
}
typedef std::unordered_map<uint32, ScriptPointVector> PointMoveMap;
//Database
@@ -75,6 +80,6 @@ class SystemMgr
static ScriptPointVector const _empty;
};
#define sScriptSystemMgr ACE_Singleton<SystemMgr, ACE_Null_Mutex>::instance()
#define sScriptSystemMgr SystemMgr::instance()
#endif
+7 -4
View File
@@ -19,7 +19,6 @@
#define TRINITY_PACKETLOG_H
#include "Common.h"
#include <ace/Singleton.h>
enum Direction
{
@@ -31,13 +30,17 @@ class WorldPacket;
class PacketLog
{
friend class ACE_Singleton<PacketLog, ACE_Thread_Mutex>;
private:
PacketLog();
~PacketLog();
public:
static PacketLog* instance()
{
static PacketLog* instance = new PacketLog();
return instance;
}
void Initialize();
bool CanLogPacket() const { return (_file != NULL); }
void LogPacket(WorldPacket const& packet, Direction direction);
@@ -46,5 +49,5 @@ class PacketLog
FILE* _file;
};
#define sPacketLog ACE_Singleton<PacketLog, ACE_Thread_Mutex>::instance()
#define sPacketLog PacketLog::instance()
#endif
+1 -1
View File
@@ -780,7 +780,7 @@ void WorldSession::SaveTutorialsData(SQLTransaction &trans)
PreparedStatement* stmt = CharacterDatabase.GetPreparedStatement(CHAR_SEL_HAS_TUTORIALS);
stmt->setUInt32(0, GetAccountId());
bool hasTutorials = !CharacterDatabase.Query(stmt).null();
bool hasTutorials = !CharacterDatabase.Query(stmt);
// Modify data in DB
stmt = CharacterDatabase.GetPreparedStatement(hasTutorials ? CHAR_UPD_TUTORIALS : CHAR_INS_TUTORIALS);
for (uint8 i = 0; i < MAX_ACCOUNT_TUTORIAL_VALUES; ++i)
+8 -4
View File
@@ -26,7 +26,6 @@
#define __WORLDSOCKETMGR_H
#include <ace/Basic_Types.h>
#include <ace/Singleton.h>
#include <ace/Thread_Mutex.h>
class WorldSocket;
@@ -36,9 +35,14 @@ class ACE_Event_Handler;
/// Manages all sockets connected to peers and network threads
class WorldSocketMgr
{
public:
friend class WorldSocket;
friend class ACE_Singleton<WorldSocketMgr, ACE_Thread_Mutex>;
public:
static WorldSocketMgr* instance()
{
static WorldSocketMgr* instance = new WorldSocketMgr();
return instance;
}
/// Start network, listen at address:port .
int StartNetwork(ACE_UINT16 port, const char* address);
@@ -68,7 +72,7 @@ private:
class WorldSocketAcceptor* m_Acceptor;
};
#define sWorldSocketMgr ACE_Singleton<WorldSocketMgr, ACE_Thread_Mutex>::instance()
#define sWorldSocketMgr WorldSocketMgr::instance()
#endif
/// @}
+8 -4
View File
@@ -21,8 +21,6 @@
// For static or at-server-startup loaded spell data
#include <ace/Singleton.h>
#include "Define.h"
#include "DBCStructure.h"
#include "SharedDefines.h"
@@ -603,7 +601,6 @@ bool IsDiminishingReturnsGroupDurationLimited(DiminishingGroup group);
class SpellMgr
{
friend class ACE_Singleton<SpellMgr, ACE_Null_Mutex>;
// Constructors
private:
SpellMgr();
@@ -611,6 +608,13 @@ class SpellMgr
// Accessors (const or static functions)
public:
static SpellMgr* instance()
{
static SpellMgr* instance = new SpellMgr();
return instance;
}
// Spell correctness for client using
static bool IsSpellValid(SpellInfo const* spellInfo, Player* player = NULL, bool msg = true);
@@ -766,6 +770,6 @@ class SpellMgr
SpellInfoMap mSpellInfoMap;
};
#define sSpellMgr ACE_Singleton<SpellMgr, ACE_Null_Mutex>::instance()
#define sSpellMgr SpellMgr::instance()
#endif
+10 -4
View File
@@ -82,11 +82,17 @@ typedef std::unordered_map<uint64, CreatureTextRepeatGroup> CreatureTextRepeatMa
class CreatureTextMgr
{
friend class ACE_Singleton<CreatureTextMgr, ACE_Null_Mutex>;
CreatureTextMgr() { };
private:
CreatureTextMgr() { };
~CreatureTextMgr() { };
public:
~CreatureTextMgr() { };
static CreatureTextMgr* instance()
{
static CreatureTextMgr* instance = new CreatureTextMgr();
return instance;
}
void LoadCreatureTexts();
void LoadCreatureTextLocales();
CreatureTextMap const& GetTextMap() const { return mTextMap; }
@@ -113,7 +119,7 @@ class CreatureTextMgr
LocaleCreatureTextMap mLocaleTextMap;
};
#define sCreatureTextMgr ACE_Singleton<CreatureTextMgr, ACE_Null_Mutex>::instance()
#define sCreatureTextMgr CreatureTextMgr::instance()
template<class Builder>
class CreatureTextLocalizer
+7 -4
View File
@@ -19,7 +19,6 @@
#define _TICKETMGR_H
#include <string>
#include <ace/Singleton.h>
#include "ObjectMgr.h"
@@ -174,13 +173,17 @@ typedef std::map<uint32, GmTicket*> GmTicketList;
class TicketMgr
{
friend class ACE_Singleton<TicketMgr, ACE_Null_Mutex>;
private:
TicketMgr();
~TicketMgr();
public:
static TicketMgr* instance()
{
static TicketMgr* instance = new TicketMgr();
return instance;
}
void LoadTickets();
void LoadSurveys();
@@ -246,6 +249,6 @@ protected:
uint64 _lastChange;
};
#define sTicketMgr ACE_Singleton<TicketMgr, ACE_Null_Mutex>::instance()
#define sTicketMgr TicketMgr::instance()
#endif // _TICKETMGR_H
+10 -4
View File
@@ -48,11 +48,17 @@ struct WardenCheckResult
class WardenCheckMgr
{
friend class ACE_Singleton<WardenCheckMgr, ACE_Null_Mutex>;
WardenCheckMgr();
~WardenCheckMgr();
private:
WardenCheckMgr();
~WardenCheckMgr();
public:
static WardenCheckMgr* instance()
{
static WardenCheckMgr* instance = new WardenCheckMgr();
return instance;
}
// We have a linear key without any gaps, so we use vector for fast access
typedef std::vector<WardenCheck*> CheckContainer;
typedef std::map<uint32, WardenCheckResult*> CheckResultContainer;
@@ -73,6 +79,6 @@ class WardenCheckMgr
CheckResultContainer CheckResultStore;
};
#define sWardenCheckMgr ACE_Singleton<WardenCheckMgr, ACE_Null_Mutex>::instance()
#define sWardenCheckMgr WardenCheckMgr::instance()
#endif
+1 -1
View File
@@ -34,7 +34,7 @@ namespace WeatherMgr
namespace
{
typedef std::unordered_map<uint32, Trinity::AutoPtr<Weather, ACE_Null_Mutex> > WeatherMap;
typedef std::unordered_map<uint32, std::shared_ptr<Weather> > WeatherMap;
typedef std::unordered_map<uint32, WeatherData> WeatherZoneMap;
WeatherMap m_weathers;
+1 -3
View File
@@ -668,7 +668,7 @@ void World::LoadConfigSettings(bool reload)
m_bool_configs[CONFIG_ALLOW_TWO_SIDE_INTERACTION_GROUP] = sConfigMgr->GetBoolDefault("AllowTwoSide.Interaction.Group", false);
m_bool_configs[CONFIG_ALLOW_TWO_SIDE_INTERACTION_GUILD] = sConfigMgr->GetBoolDefault("AllowTwoSide.Interaction.Guild", false);
m_bool_configs[CONFIG_ALLOW_TWO_SIDE_INTERACTION_AUCTION] = sConfigMgr->GetBoolDefault("AllowTwoSide.Interaction.Auction", false);
m_bool_configs[CONFIG_ALLOW_TWO_SIDE_TRADE] = sConfigMgr->GetBoolDefault("AllowTwoSide.trade", false);
m_bool_configs[CONFIG_ALLOW_TWO_SIDE_TRADE] = sConfigMgr->GetBoolDefault("AllowTwoSide.Trade", false);
m_int_configs[CONFIG_STRICT_PLAYER_NAMES] = sConfigMgr->GetIntDefault ("StrictPlayerNames", 0);
m_int_configs[CONFIG_STRICT_CHARTER_NAMES] = sConfigMgr->GetIntDefault ("StrictCharterNames", 0);
m_int_configs[CONFIG_STRICT_PET_NAMES] = sConfigMgr->GetIntDefault ("StrictPetNames", 0);
@@ -1255,8 +1255,6 @@ void World::LoadConfigSettings(bool reload)
m_bool_configs[CONFIG_IP_BASED_ACTION_LOGGING] = sConfigMgr->GetBoolDefault("Allow.IP.Based.Action.Logging", false);
m_bool_configs[CONFIG_IP_BASED_LOGIN_LOGGING] = sConfigMgr->GetBoolDefault("Wrong.Password.Login.Logging", false);
// call ScriptMgr if we're reloading the configuration
if (reload)
sScriptMgr->OnConfigLoad(reload);
+10 -7
View File
@@ -25,9 +25,7 @@
#include "Common.h"
#include "Timer.h"
#include <ace/Singleton.h>
#include <ace/Atomic_Op.h>
#include <ace/Null_Mutex.h>
#include "SharedDefines.h"
#include "QueryResult.h"
#include "Callback.h"
@@ -156,7 +154,6 @@ enum WorldBoolConfigs
CONFIG_STATS_LIMITS_ENABLE,
CONFIG_INSTANCES_RESET_ANNOUNCE,
CONFIG_IP_BASED_ACTION_LOGGING,
CONFIG_IP_BASED_LOGIN_LOGGING,
BOOL_CONFIG_VALUE_COUNT
};
@@ -520,10 +517,13 @@ struct CharacterNameData
class World
{
public:
static ACE_Atomic_Op<ACE_Thread_Mutex, uint32> m_worldLoopCounter;
static World* instance()
{
static World* instance = new World();
return instance;
}
World();
~World();
static ACE_Atomic_Op<ACE_Thread_Mutex, uint32> m_worldLoopCounter;
WorldSession* FindSession(uint32 id) const;
void AddSession(WorldSession* s);
@@ -758,6 +758,9 @@ class World
void ResetRandomBG();
void ResetGuildCap();
private:
World();
~World();
static ACE_Atomic_Op<ACE_Thread_Mutex, bool> m_stopEvent;
static uint8 m_ExitCode;
uint32 m_ShutdownTimer;
@@ -845,6 +848,6 @@ class World
extern uint32 realmID;
#define sWorld ACE_Singleton<World, ACE_Null_Mutex>::instance()
#define sWorld World::instance()
#endif
/// @}
+1 -1
View File
@@ -19,8 +19,8 @@
#ifndef _AUTH_SARC4_H
#define _AUTH_SARC4_H
#include "Define.h"
#include <openssl/evp.h>
#include "Define.h"
class ARC4
{
@@ -22,7 +22,6 @@
#include <memory>
#include "Define.h"
struct bignum_st;
class BigNumber
@@ -18,8 +18,6 @@
#ifndef _DATABASEWORKERPOOL_H
#define _DATABASEWORKERPOOL_H
#include <ace/Thread_Mutex.h>
#include "Common.h"
#include "Callback.h"
#include "MySQLConnection.h"
@@ -51,7 +49,6 @@ class DatabaseWorkerPool
/* Activity state */
DatabaseWorkerPool() : _connectionInfo(NULL)
{
_messageQueue = new ACE_Message_Queue<ACE_SYNCH>(8 * 1024 * 1024, 8 * 1024 * 1024);
_queue = new ProducerConsumerQueue<SQLOperation*>();
memset(_connectionCount, 0, sizeof(_connectionCount));
_connections.resize(IDX_SIZE);
@@ -125,9 +122,7 @@ class DatabaseWorkerPool
for (uint8 i = 0; i < _connectionCount[IDX_SYNCH]; ++i)
_connections[IDX_SYNCH][i]->Close();
//! Deletes the ACE_Activation_Queue object and its underlying ACE_Message_Queue
delete _queue;
delete _messageQueue;
TC_LOG_INFO("sql.driver", "All connections on DatabasePool '%s' closed.", GetDatabaseName());
@@ -410,7 +405,7 @@ class DatabaseWorkerPool
//! Will be wrapped in a transaction if valid object is present, otherwise executed standalone.
void ExecuteOrAppend(SQLTransaction& trans, PreparedStatement* stmt)
{
if (trans.null())
if (!trans)
Execute(stmt);
else
trans->Append(stmt);
@@ -420,7 +415,7 @@ class DatabaseWorkerPool
//! Will be wrapped in a transaction if valid object is present, otherwise executed standalone.
void ExecuteOrAppend(SQLTransaction& trans, const char* sql)
{
if (trans.null())
if (!trans)
Execute(sql);
else
trans->Append(sql);
@@ -517,7 +512,6 @@ class DatabaseWorkerPool
IDX_SIZE
};
ACE_Message_Queue<ACE_SYNCH>* _messageQueue; //! Message Queue used by ACE_Activation_Queue
ProducerConsumerQueue<SQLOperation*>* _queue; //! Queue shared by async worker threads.
std::vector< std::vector<T*> > _connections;
uint32 _connectionCount[2]; //! Counter of MySQL connections;
+3 -5
View File
@@ -15,8 +15,6 @@
* with this program. If not, see <http://www.gnu.org/licenses/>.
*/
#include <ace/Activation_Queue.h>
#include "DatabaseWorkerPool.h"
#include "Transaction.h"
#include "Util.h"
@@ -100,13 +98,13 @@ class MySQLConnection
{
/// 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; }
@@ -131,7 +129,7 @@ class MySQLConnection
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;
+3 -5
View File
@@ -19,9 +19,7 @@
#ifndef QUERYRESULT_H
#define QUERYRESULT_H
#include "AutoPtr.h"
#include <ace/Thread_Mutex.h>
#include <memory>
#include "Field.h"
#ifdef _WIN32
@@ -60,7 +58,7 @@ class ResultSet
ResultSet& operator=(ResultSet const& right) = delete;
};
typedef Trinity::AutoPtr<ResultSet, ACE_Thread_Mutex> QueryResult;
typedef std::shared_ptr<ResultSet> QueryResult;
class PreparedResultSet
{
@@ -107,7 +105,7 @@ class PreparedResultSet
PreparedResultSet& operator=(PreparedResultSet const& right) = delete;
};
typedef Trinity::AutoPtr<PreparedResultSet, ACE_Thread_Mutex> PreparedQueryResult;
typedef std::shared_ptr<PreparedResultSet> PreparedQueryResult;
#endif
+1 -1
View File
@@ -50,7 +50,7 @@ class Transaction
bool _cleanedUp;
};
typedef Trinity::AutoPtr<Transaction, ACE_Thread_Mutex> SQLTransaction;
typedef std::shared_ptr<Transaction> SQLTransaction;
/*! Low level class*/
class TransactionTask : public SQLOperation
+5 -6
View File
@@ -18,17 +18,15 @@
#include "Errors.h"
#include <ace/Stack_Trace.h>
#include <ace/OS_NS_unistd.h>
#include <cstdlib>
#include <thread>
namespace Trinity {
void Assert(char const* file, int line, char const* function, char const* message)
{
ACE_Stack_Trace st;
fprintf(stderr, "\n%s:%i in %s ASSERTION FAILED:\n %s\n%s\n",
file, line, function, message, st.c_str());
fprintf(stderr, "\n%s:%i in %s ASSERTION FAILED:\n %s\n",
file, line, function, message);
*((volatile int*)NULL) = 0;
exit(1);
}
@@ -37,7 +35,8 @@ void Fatal(char const* file, int line, char const* function, char const* message
{
fprintf(stderr, "\n%s:%i in %s FATAL ERROR:\n %s\n",
file, line, function, message);
ACE_OS::sleep(10);
std::this_thread::sleep_for(std::chrono::seconds(10));
*((volatile int*)NULL) = 0;
exit(1);
}
+2 -2
View File
@@ -18,10 +18,10 @@
#ifndef APPENDER_H
#define APPENDER_H
#include "Define.h"
#include <time.h>
#include <unordered_map>
#include <string>
#include <time.h>
#include "Define.h"
// Values assigned have their equivalent in enum ACE_Log_Priority
enum LogLevel
+1 -1
View File
@@ -18,8 +18,8 @@
#ifndef APPENDERCONSOLE_H
#define APPENDERCONSOLE_H
#include "Appender.h"
#include <string>
#include "Appender.h"
enum ColorTypes
{
+1 -1
View File
@@ -18,8 +18,8 @@
#ifndef APPENDERFILE_H
#define APPENDERFILE_H
#include "Appender.h"
#include <atomic>
#include "Appender.h"
class AppenderFile: public Appender
{
+1 -5
View File
@@ -26,10 +26,6 @@ typedef std::promise<QueryResult> QueryResultPromise;
typedef std::future<PreparedQueryResult> PreparedQueryResultFuture;
typedef std::promise<PreparedQueryResult> PreparedQueryResultPromise;
/*! A simple template using ACE_Future to manage callbacks from the thread and object that
issued the request. <ParamType> is variable type of parameter that is used as parameter
for the callback function.
*/
#define CALLBACK_STAGE_INVALID uint8(-1)
template <typename Result, typename ParamType, bool chain = false>
@@ -210,4 +206,4 @@ class QueryCallback_2
QueryCallback_2& operator=(QueryCallback_2 const& right) = delete;
};
#endif
#endif
+17 -1
View File
@@ -1,4 +1,20 @@
#include <ace/Singleton.h>
/*
* Copyright (C) 2008-2014 TrinityCore <http://www.trinitycore.org/>
*
* This program is free software; you can redistribute it and/or modify it
* under the terms of the GNU General Public License as published by the
* Free Software Foundation; either version 2 of the License, or (at your
* option) any later version.
*
* This program is distributed in the hope that it will be useful, but WITHOUT
* ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
* FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for
* more details.
*
* You should have received a copy of the GNU General Public License along
* with this program. If not, see <http://www.gnu.org/licenses/>.
*/
#include <ace/Thread_Mutex.h>
#include <ace/Log_Msg.h>
@@ -8,7 +8,6 @@
class DelayExecutor : protected ACE_Task_Base
{
public:
DelayExecutor();
virtual ~DelayExecutor();
@@ -25,7 +24,6 @@ class DelayExecutor : protected ACE_Task_Base
virtual int svc();
private:
ACE_Activation_Queue queue_;
ACE_Method_Request* pre_svc_hook_;
ACE_Method_Request* post_svc_hook_;
+20 -35
View File
@@ -22,8 +22,6 @@
#include <thread>
#include <ace/Sig_Handler.h>
#include "Common.h"
#include "SystemConfig.h"
#include "SignalHandler.h"
@@ -46,6 +44,7 @@
#include "BigNumber.h"
#include "OpenSSLCrypto.h"
#include <boost/asio.hpp>
#ifdef _WIN32
#include "ServiceWin32.h"
@@ -58,27 +57,22 @@ extern int m_ServiceStatus;
#define PROCESS_HIGH_PRIORITY -15 // [-20, 19], default is 0
#endif
/// Handle worldservers's termination signals
class WorldServerSignalHandler : public Trinity::SignalHandler
boost::asio::io_service _ioService;
void SignalHandler(const boost::system::error_code& error, int signalNumber)
{
public:
virtual void HandleSignal(int sigNum)
if (!error)
{
switch (signalNumber)
{
switch (sigNum)
{
case SIGINT:
World::StopNow(RESTART_EXIT_CODE);
break;
case SIGTERM:
#ifdef _WIN32
case SIGBREAK:
if (m_ServiceStatus != 1)
#endif
World::StopNow(SHUTDOWN_EXIT_CODE);
break;
}
case SIGINT:
case SIGTERM:
_ioService.stop();
break;
}
};
}
}
void FreezeDetectorThread(uint32 delayTime)
{
@@ -153,23 +147,12 @@ int Master::Run()
///- Initialize the World
sWorld->SetInitialWorldSettings();
///- Initialize the signal handlers
WorldServerSignalHandler signalINT, signalTERM;
#ifdef _WIN32
WorldServerSignalHandler signalBREAK;
#endif /* _WIN32 */
///- Register worldserver's signal handlers
ACE_Sig_Handler handle;
handle.register_handler(SIGINT, &signalINT);
handle.register_handler(SIGTERM, &signalTERM);
#ifdef _WIN32
handle.register_handler(SIGBREAK, &signalBREAK);
#endif
// Set signal handlers
boost::asio::signal_set signals(_ioService, SIGINT, SIGTERM);
signals.async_wait(SignalHandler);
///- Launch WorldRunnable thread
std::thread worldThread(WorldThread);
std::thread worldThread(WorldThread, std::ref(_ioService));
std::thread* cliThread = nullptr;
@@ -286,6 +269,8 @@ int Master::Run()
TC_LOG_INFO("server.worldserver", "%s (worldserver-daemon) ready...", _FULLVERSION);
_ioService.run();
// when the main thread closes the singletons get unloaded
// since worldrunnable uses them, it will crash if unloaded after master
worldThread.join();
+7 -1
View File
@@ -29,6 +29,12 @@
class Master
{
public:
static Master* instance()
{
static Master* instance = new Master();
return instance;
}
int Run();
private:
@@ -38,7 +44,7 @@ class Master
void ClearOnlineAccounts();
};
#define sMaster ACE_Singleton<Master, ACE_Null_Mutex>::instance()
#define sMaster Master::instance()
#endif
@@ -42,7 +42,7 @@ extern int m_ServiceStatus;
#endif
/// Heartbeat for the World
void WorldThread()
void WorldThread(boost::asio::io_service& ioService)
{
uint32 realCurrTime = 0;
uint32 realPrevTime = getMSTime();
@@ -84,6 +84,8 @@ void WorldThread()
#endif
}
ioService.stop();
sScriptMgr->OnShutdown();
sWorld->KickAll(); // save and kick all players
@@ -23,7 +23,9 @@
#ifndef __WORLDRUNNABLE_H
#define __WORLDRUNNABLE_H
void WorldThread();
#include <boost/asio.hpp>
void WorldThread(boost::asio::io_service& ioService);
#endif