mirror of
https://github.com/mod-playerbots/azerothcore-wotlk.git
synced 2026-02-01 18:13:48 +00:00
Rewritten Threading system using c++11 std instead of ACE
It also allow full compilation with clang under all supported platforms Need tests
This commit is contained in:
@@ -134,7 +134,7 @@ typedef struct AuthHandler
|
||||
#endif
|
||||
|
||||
// Launch a thread to transfer a patch to the client
|
||||
class PatcherRunnable: public ACE_Based::Runnable
|
||||
class PatcherRunnable: public ACORE::Runnable
|
||||
{
|
||||
public:
|
||||
PatcherRunnable(class AuthSocket*);
|
||||
@@ -1010,7 +1010,7 @@ bool AuthSocket::_HandleXferResume()
|
||||
socket().recv((char*)&start, sizeof(start));
|
||||
fseek(pPatch, long(start), 0);
|
||||
|
||||
ACE_Based::Thread u(new PatcherRunnable(this));
|
||||
ACORE::Thread u(new PatcherRunnable(this));
|
||||
return true;
|
||||
}
|
||||
|
||||
@@ -1042,7 +1042,7 @@ bool AuthSocket::_HandleXferAccept()
|
||||
socket().recv_skip(1); // clear input buffer
|
||||
fseek(pPatch, 0, 0);
|
||||
|
||||
ACE_Based::Thread u(new PatcherRunnable(this));
|
||||
ACORE::Thread u(new PatcherRunnable(this));
|
||||
return true;
|
||||
}
|
||||
|
||||
|
||||
@@ -9,7 +9,7 @@
|
||||
|
||||
#include "Common.h"
|
||||
#include <ace/Singleton.h>
|
||||
#include <ace/Atomic_Op.h>
|
||||
#include <atomic>
|
||||
|
||||
#include "ObjectMgr.h"
|
||||
#include "DBCStores.h"
|
||||
@@ -1083,7 +1083,7 @@ class ScriptMgr
|
||||
uint32 _scriptCount;
|
||||
|
||||
//atomic op counter for active scripts amount
|
||||
ACE_Atomic_Op<ACE_Thread_Mutex, long> _scheduledScripts;
|
||||
std::atomic_long _scheduledScripts;
|
||||
};
|
||||
|
||||
template<class TScript>
|
||||
|
||||
@@ -344,10 +344,10 @@ class WorldSession
|
||||
void SetLatency(uint32 latency) { m_latency = latency; }
|
||||
void ResetClientTimeDelay() { m_clientTimeDelay = 0; }
|
||||
|
||||
ACE_Atomic_Op<ACE_Thread_Mutex, time_t> m_timeOutTime;
|
||||
std::atomic<time_t> m_timeOutTime;
|
||||
void UpdateTimeOutTime(uint32 diff)
|
||||
{
|
||||
if (time_t(diff) > m_timeOutTime.value())
|
||||
if (time_t(diff) > m_timeOutTime)
|
||||
m_timeOutTime = 0;
|
||||
else
|
||||
m_timeOutTime -= diff;
|
||||
|
||||
@@ -18,7 +18,7 @@
|
||||
#include <ace/TP_Reactor.h>
|
||||
#include <ace/Dev_Poll_Reactor.h>
|
||||
#include <ace/Guard_T.h>
|
||||
#include <ace/Atomic_Op.h>
|
||||
#include <atomic>
|
||||
#include <ace/os_include/arpa/os_inet.h>
|
||||
#include <ace/os_include/netinet/os_tcp.h>
|
||||
#include <ace/os_include/sys/os_types.h>
|
||||
@@ -92,7 +92,7 @@ class ReactorRunnable : protected ACE_Task_Base
|
||||
|
||||
long Connections()
|
||||
{
|
||||
return static_cast<long> (m_Connections.value());
|
||||
return static_cast<long> (m_Connections);
|
||||
}
|
||||
|
||||
int AddSocket (WorldSocket* sock)
|
||||
@@ -186,7 +186,7 @@ class ReactorRunnable : protected ACE_Task_Base
|
||||
}
|
||||
|
||||
private:
|
||||
typedef ACE_Atomic_Op<ACE_SYNCH_MUTEX, long> AtomicInt;
|
||||
typedef std::atomic_long AtomicInt;
|
||||
typedef std::set<WorldSocket*> SocketSet;
|
||||
|
||||
ACE_Reactor* m_Reactor;
|
||||
|
||||
@@ -12,7 +12,7 @@
|
||||
#define __CLIRUNNABLE_H
|
||||
|
||||
/// Command Line Interface handling thread
|
||||
class CliRunnable : public ACE_Based::Runnable
|
||||
class CliRunnable : public ACORE::Runnable
|
||||
{
|
||||
public:
|
||||
void run();
|
||||
|
||||
@@ -71,7 +71,7 @@ class WorldServerSignalHandler : public Trinity::SignalHandler
|
||||
}
|
||||
};
|
||||
|
||||
class FreezeDetectorRunnable : public ACE_Based::Runnable
|
||||
class FreezeDetectorRunnable : public ACORE::Runnable
|
||||
{
|
||||
private:
|
||||
uint32 _loops;
|
||||
@@ -101,7 +101,7 @@ public:
|
||||
ASSERT(false);
|
||||
}
|
||||
|
||||
ACE_Based::Thread::Sleep(1000);
|
||||
ACORE::Thread::Sleep(1000);
|
||||
}
|
||||
sLog->outString("Anti-freeze thread exiting without problems.");
|
||||
}
|
||||
@@ -171,10 +171,10 @@ int Master::Run()
|
||||
//handle.register_handler(SIGSEGV, &signalSEGV);
|
||||
|
||||
///- Launch WorldRunnable thread
|
||||
ACE_Based::Thread worldThread(new WorldRunnable);
|
||||
worldThread.setPriority(ACE_Based::Highest);
|
||||
ACORE::Thread worldThread(new WorldRunnable);
|
||||
worldThread.setPriority(ACORE::Priority_Highest);
|
||||
|
||||
ACE_Based::Thread* cliThread = NULL;
|
||||
ACORE::Thread* cliThread = NULL;
|
||||
|
||||
#ifdef _WIN32
|
||||
if (sConfigMgr->GetBoolDefault("Console.Enable", true) && (m_ServiceStatus == -1)/* need disable console in service mode*/)
|
||||
@@ -183,14 +183,14 @@ int Master::Run()
|
||||
#endif
|
||||
{
|
||||
///- Launch CliRunnable thread
|
||||
cliThread = new ACE_Based::Thread(new CliRunnable);
|
||||
cliThread = new ACORE::Thread(new CliRunnable);
|
||||
}
|
||||
|
||||
ACE_Based::Thread rarThread(new RARunnable);
|
||||
ACORE::Thread rarThread(new RARunnable);
|
||||
|
||||
// pussywizard:
|
||||
ACE_Based::Thread auctionLising_thread(new AuctionListingRunnable);
|
||||
auctionLising_thread.setPriority(ACE_Based::High);
|
||||
ACORE::Thread auctionLising_thread(new AuctionListingRunnable);
|
||||
auctionLising_thread.setPriority(ACORE::Priority_High);
|
||||
|
||||
#if defined(_WIN32) || defined(__linux__)
|
||||
|
||||
@@ -262,21 +262,21 @@ int Master::Run()
|
||||
#endif
|
||||
|
||||
// Start soap serving thread
|
||||
ACE_Based::Thread* soapThread = NULL;
|
||||
ACORE::Thread* soapThread = NULL;
|
||||
if (sConfigMgr->GetBoolDefault("SOAP.Enabled", false))
|
||||
{
|
||||
TCSoapRunnable* runnable = new TCSoapRunnable();
|
||||
runnable->SetListenArguments(sConfigMgr->GetStringDefault("SOAP.IP", "127.0.0.1"), uint16(sConfigMgr->GetIntDefault("SOAP.Port", 7878)));
|
||||
soapThread = new ACE_Based::Thread(runnable);
|
||||
soapThread = new ACORE::Thread(runnable);
|
||||
}
|
||||
|
||||
// Start up freeze catcher thread
|
||||
ACE_Based::Thread* freezeThread = NULL;
|
||||
ACORE::Thread* freezeThread = NULL;
|
||||
if (uint32 freezeDelay = sConfigMgr->GetIntDefault("MaxCoreStuckTime", 0))
|
||||
{
|
||||
FreezeDetectorRunnable* runnable = new FreezeDetectorRunnable(freezeDelay*1000);
|
||||
freezeThread = new ACE_Based::Thread(runnable);
|
||||
freezeThread->setPriority(ACE_Based::Highest);
|
||||
freezeThread = new ACORE::Thread(runnable);
|
||||
freezeThread->setPriority(ACORE::Priority_Highest);
|
||||
}
|
||||
|
||||
///- Launch the world listener socket
|
||||
|
||||
@@ -16,7 +16,7 @@
|
||||
|
||||
#include <ace/Reactor.h>
|
||||
|
||||
class RARunnable : public ACE_Based::Runnable
|
||||
class RARunnable : public ACORE::Runnable
|
||||
{
|
||||
public:
|
||||
RARunnable();
|
||||
|
||||
@@ -15,7 +15,7 @@
|
||||
#include <ace/Task.h>
|
||||
#include <Threading.h>
|
||||
|
||||
class TCSoapRunnable : public ACE_Based::Runnable
|
||||
class TCSoapRunnable : public ACORE::Runnable
|
||||
{
|
||||
public:
|
||||
TCSoapRunnable() : _port(0) { }
|
||||
|
||||
@@ -51,7 +51,7 @@ void WorldRunnable::run()
|
||||
avgDiffTracker.Update(executionTimeDiff > WORLD_SLEEP_CONST ? executionTimeDiff : WORLD_SLEEP_CONST);
|
||||
|
||||
if (executionTimeDiff < WORLD_SLEEP_CONST)
|
||||
ACE_Based::Thread::Sleep(WORLD_SLEEP_CONST-executionTimeDiff);
|
||||
ACORE::Thread::Sleep(WORLD_SLEEP_CONST-executionTimeDiff);
|
||||
|
||||
#ifdef _WIN32
|
||||
if (m_ServiceStatus == 0)
|
||||
@@ -118,7 +118,7 @@ void AuctionListingRunnable::run()
|
||||
}
|
||||
}
|
||||
}
|
||||
ACE_Based::Thread::Sleep(1);
|
||||
ACORE::Thread::Sleep(1);
|
||||
}
|
||||
sLog->outString("Auction House Listing thread exiting without problems.");
|
||||
}
|
||||
|
||||
@@ -12,13 +12,13 @@
|
||||
#define __WORLDRUNNABLE_H
|
||||
|
||||
/// Heartbeat thread for the World
|
||||
class WorldRunnable : public ACE_Based::Runnable
|
||||
class WorldRunnable : public ACORE::Runnable
|
||||
{
|
||||
public:
|
||||
void run();
|
||||
};
|
||||
|
||||
class AuctionListingRunnable : public ACE_Based::Runnable
|
||||
class AuctionListingRunnable : public ACORE::Runnable
|
||||
{
|
||||
public:
|
||||
void run();
|
||||
|
||||
Reference in New Issue
Block a user