本文整理汇总了C++中FreezeDetectorRunnable类的典型用法代码示例。如果您正苦于以下问题:C++ FreezeDetectorRunnable类的具体用法?C++ FreezeDetectorRunnable怎么用?C++ FreezeDetectorRunnable使用的例子?那么, 这里精选的类代码示例或许可以为您提供帮助。
在下文中一共展示了FreezeDetectorRunnable类的8个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。
示例1: CreatePIDFile
//.........这里部分代码省略.........
else
{
if(SetProcessAffinityMask(hProcess,curAff))
sLog.outString("Using processors (bitmask, hex): %x", curAff);
else
sLog.outError("Can't set used processors (hex): %x",curAff);
}
}
sLog.outString();
}
bool Prio = sConfig.GetBoolDefault("ProcessPriority", false);
// if(Prio && (m_ServiceStatus == -1)/* need set to default process priority class in service mode*/)
if(Prio)
{
if(SetPriorityClass(hProcess,HIGH_PRIORITY_CLASS))
sLog.outString("mangosd process priority class set to HIGH");
else
sLog.outError("ERROR: Can't set mangosd process priority class.");
sLog.outString();
}
}
#endif
uint32 realCurrTime, realPrevTime;
realCurrTime = realPrevTime = getMSTime();
uint32 socketSelecttime = sWorld.getConfig(CONFIG_SOCKET_SELECTTIME);
///- Start up freeze catcher thread
if(uint32 freeze_delay = sConfig.GetIntDefault("MaxCoreStuckTime", 0))
{
FreezeDetectorRunnable *fdr = new FreezeDetectorRunnable();
fdr->SetDelayTime(freeze_delay*1000);
ACE_Based::Thread freeze_thread(fdr);
freeze_thread.setPriority(ACE_Based::Highest);
}
///- Launch the world listener socket
port_t wsport = sWorld.getConfig (CONFIG_PORT_WORLD);
std::string bind_ip = sConfig.GetStringDefault ("BindIP", "0.0.0.0");
if (sWorldSocketMgr->StartNetwork (wsport, bind_ip.c_str ()) == -1)
{
sLog.outError ("Failed to start network");
World::StopNow(ERROR_EXIT_CODE);
// go down and shutdown the server
}
sWorldSocketMgr->Wait ();
// set server offline
loginDatabase.PExecute("UPDATE realmlist SET color = 2 WHERE id = '%d'",realmID);
///- Remove signal handling before leaving
_UnhookSignals();
// when the main thread closes the singletons get unloaded
// since worldrunnable uses them, it will crash if unloaded after master
world_thread.wait();
rar_thread.wait ();
///- Clean database before leaving
clearOnlineAccounts();
示例2: CreatePIDFile
//.........这里部分代码省略.........
else
sLog->outError("Can't set used processors (hex): %x", curAff);
}
}
sLog->outString("");
}
bool Prio = ConfigMgr::GetBoolDefault("ProcessPriority", false);
//if (Prio && (m_ServiceStatus == -1) /* need set to default process priority class in service mode*/)
if (Prio)
{
if (SetPriorityClass(hProcess, HIGH_PRIORITY_CLASS))
sLog->outString("worldserver process priority class set to HIGH");
else
sLog->outError("Can't set worldserver process priority class.");
sLog->outString("");
}
}
#endif
//Start soap serving thread
ACE_Based::Thread* soap_thread = NULL;
if (ConfigMgr::GetBoolDefault("SOAP.Enabled", false))
{
TCSoapRunnable* runnable = new TCSoapRunnable();
runnable->setListenArguments(ConfigMgr::GetStringDefault("SOAP.IP", "127.0.0.1"), ConfigMgr::GetIntDefault("SOAP.Port", 7878));
soap_thread = new ACE_Based::Thread(runnable);
}
///- Start up freeze catcher thread
if (uint32 freeze_delay = ConfigMgr::GetIntDefault("MaxCoreStuckTime", 0))
{
FreezeDetectorRunnable* fdr = new FreezeDetectorRunnable();
fdr->SetDelayTime(freeze_delay*1000);
ACE_Based::Thread freeze_thread(fdr);
freeze_thread.setPriority(ACE_Based::Highest);
}
///- Launch the world listener socket
uint16 wsport = sWorld->getIntConfig(CONFIG_PORT_WORLD);
std::string bind_ip = ConfigMgr::GetStringDefault("BindIP", "0.0.0.0");
if (sWorldSocketMgr->StartNetwork(wsport, bind_ip.c_str ()) == -1)
{
sLog->outError("Failed to start network");
World::StopNow(ERROR_EXIT_CODE);
// go down and shutdown the server
}
// set server online (allow connecting now)
LoginDatabase.DirectPExecute("UPDATE realmlist SET flag = flag & ~%u, population = 0 WHERE id = '%u'", REALM_FLAG_INVALID, realmID);
sLog->outString("%s (worldserver-daemon) ready...", _FULLVERSION);
// when the main thread closes the singletons get unloaded
// since worldrunnable uses them, it will crash if unloaded after master
world_thread.wait();
rar_thread.wait();
if (soap_thread)
{
soap_thread->wait();
soap_thread->destroy();
delete soap_thread;
}
示例3: TC_LOG_INFO
//.........这里部分代码省略.........
TC_LOG_ERROR("server.worldserver", "Can't set used processors (hex): %x, error: %s", affinity, strerror(errno));
else
{
CPU_ZERO(&mask);
sched_getaffinity(0, sizeof(mask), &mask);
TC_LOG_INFO("server.worldserver", "Using processors (bitmask, hex): %lx", *(__cpu_mask*)(&mask));
}
}
if (highPriority)
{
if (setpriority(PRIO_PROCESS, 0, PROCESS_HIGH_PRIORITY))
TC_LOG_ERROR("server.worldserver", "Can't set worldserver process priority class, error: %s", strerror(errno));
else
TC_LOG_INFO("server.worldserver", "worldserver process priority class set to %i", getpriority(PRIO_PROCESS, 0));
}
#endif
#endif
//Start soap serving thread
ACE_Based::Thread* soapThread = nullptr;
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);
}
///- Start up freeze catcher thread
if (uint32 freezeDelay = sConfigMgr->GetIntDefault("MaxCoreStuckTime", 0))
{
FreezeDetectorRunnable* fdr = new FreezeDetectorRunnable();
fdr->SetDelayTime(freezeDelay * 1000);
ACE_Based::Thread freezeThread(fdr);
freezeThread.setPriority(ACE_Based::Highest);
}
///- Launch the world listener socket
uint16 worldPort = uint16(sWorld->getIntConfig(CONFIG_PORT_WORLD));
std::string bindIp = sConfigMgr->GetStringDefault("BindIP", "0.0.0.0");
if (sWorldSocketMgr->StartNetwork(worldPort, bindIp.c_str()) == -1)
{
TC_LOG_ERROR("server.worldserver", "Failed to start network");
World::StopNow(ERROR_EXIT_CODE);
// go down and shutdown the server
}
// set server online (allow connecting now)
LoginDatabase.DirectPExecute("UPDATE realmlist SET flag = flag & ~%u, population = 0 WHERE id = '%u'", REALM_FLAG_INVALID, realmID);
TC_LOG_INFO("server.worldserver", "%s (worldserver-daemon) ready...", _FULLVERSION);
#ifdef _DEBUG
ASSERT(false); // my debugging stop
#endif
// when the main thread closes the singletons get unloaded
// since worldrunnable uses them, it will crash if unloaded after master
worldThread.wait();
rarThread.wait();
if (soapThread)
{
示例4: dup
//.........这里部分代码省略.........
sLog.outString();
}
bool Prio = sConfig.GetBoolDefault("ProcessPriority", false);
if (Prio)
{
if (SetPriorityClass(hProcess, HIGH_PRIORITY_CLASS))
sLog.outString("OregonCore process priority class set to HIGH");
else
sLog.outError("ERROR: Can't set OregonCore process priority class.");
sLog.outString();
}
}
#endif
// Start soap serving thread
ACE_Based::Thread* soap_thread = NULL;
if (sConfig.GetBoolDefault("SOAP.Enabled", false))
{
OCSoapRunnable* runnable = new OCSoapRunnable();
runnable->setListenArguments(sConfig.GetStringDefault("SOAP.IP", "127.0.0.1"), sConfig.GetIntDefault("SOAP.Port", 7878));
soap_thread = new ACE_Based::Thread(runnable);
}
//uint32 socketSelecttime = sWorld.getConfig(CONFIG_SOCKET_SELECTTIME);
// Start up freeze catcher thread
ACE_Based::Thread* freeze_thread = NULL;
if (uint32 freeze_delay = sConfig.GetIntDefault("MaxCoreStuckTime", 0))
{
FreezeDetectorRunnable* fdr = new FreezeDetectorRunnable();
fdr->SetDelayTime(freeze_delay * 1000);
freeze_thread = new ACE_Based::Thread(fdr);
freeze_thread->setPriority(ACE_Based::Highest);
}
// Launch the world listener socket
uint16 wsport = sWorld.getConfig(CONFIG_PORT_WORLD);
std::string bind_ip = sConfig.GetStringDefault ("BindIP", "0.0.0.0");
if (sWorldSocketMgr->StartNetwork (wsport, bind_ip.c_str ()) == -1)
{
sLog.outError("Failed to start network");
World::StopNow(ERROR_EXIT_CODE);
// go down and shutdown the server
// give other threads a chance to start-up so we can shutdown them safely
ACE_Based::Thread::Sleep(1500);
}
/* Run our World, we use main thread for this,
because it we need the highest priority possible */
WorldRunnable().run();
// Stop freeze protection before shutdown tasks
if (freeze_thread)
{
freeze_thread->kill(-1); // destroy
freeze_thread->wait();
delete freeze_thread;
}
sWorldSocketMgr->Wait();
示例5: CreatePIDFile
//.........这里部分代码省略.........
bool Prio = sConfig.GetBoolDefault("ProcessPriority", false);
if (Prio)
{
if (SetPriorityClass(hProcess,HIGH_PRIORITY_CLASS))
sLog.outString("BlizzLikeCore process priority class set to HIGH");
else
sLog.outError("ERROR: Can't set BlizzLikeCore process priority class.");
sLog.outString();
}
}
#endif
// Start soap serving thread
ACE_Based::Thread* soap_thread = NULL;
if (sConfig.GetBoolDefault("SOAP.Enabled", false))
{
BCSoapRunnable *runnable = new BCSoapRunnable();
runnable->setListenArguments(sConfig.GetStringDefault("SOAP.IP", "127.0.0.1"), sConfig.GetIntDefault("SOAP.Port", 7878));
soap_thread = new ACE_Based::Thread(runnable);
}
uint32 realCurrTime, realPrevTime;
realCurrTime = realPrevTime = getMSTime();
uint32 socketSelecttime = sWorld.getConfig(CONFIG_SOCKET_SELECTTIME);
// Start up freeze catcher thread
ACE_Based::Thread* freeze_thread = NULL;
if (uint32 freeze_delay = sConfig.GetIntDefault("MaxCoreStuckTime", 0))
{
FreezeDetectorRunnable *fdr = new FreezeDetectorRunnable();
fdr->SetDelayTime(freeze_delay*1000);
freeze_thread = new ACE_Based::Thread(fdr);
freeze_thread->setPriority(ACE_Based::Highest);
}
// Launch the world listener socket
uint16 wsport = sWorld.getConfig(CONFIG_PORT_WORLD);
std::string bind_ip = sConfig.GetStringDefault ("BindIP", "0.0.0.0");
if (sWorldSocketMgr->StartNetwork (wsport, bind_ip.c_str ()) == -1)
{
sLog.outError("Failed to start network");
World::StopNow(ERROR_EXIT_CODE);
// go down and shutdown the server
}
sWorldSocketMgr->Wait();
// Stop freeze protection before shutdown tasks
if (freeze_thread)
{
freeze_thread->destroy();
delete freeze_thread;
}
// Stop soap thread
if (soap_thread)
{
soap_thread->wait();
soap_thread->destroy();
delete soap_thread;
}
示例6: CreatePIDFile
//.........这里部分代码省略.........
}
sLog->outString("");
}
bool Prio = sConfig->GetBoolDefault("ProcessPriority", false);
//if (Prio && (m_ServiceStatus == -1) /* need set to default process priority class in service mode*/)
if (Prio)
{
if(SetPriorityClass(hProcess,HIGH_PRIORITY_CLASS))
sLog->outString("TrinityCore process priority class set to HIGH");
else
sLog->outError("Can't set Trinityd process priority class.");
sLog->outString("");
}
}
#endif
//Start soap serving thread
ACE_Based::Thread* soap_thread = NULL;
if (sConfig->GetBoolDefault("SOAP.Enabled", false))
{
TCSoapRunnable *runnable = new TCSoapRunnable();
runnable->setListenArguments(sConfig->GetStringDefault("SOAP.IP", "127.0.0.1"), sConfig->GetIntDefault("SOAP.Port", 7878));
soap_thread = new ACE_Based::Thread(runnable);
}
uint32 realCurrTime, realPrevTime;
realCurrTime = realPrevTime = getMSTime();
///- Start up freeze catcher thread
if (uint32 freeze_delay = sConfig->GetIntDefault("MaxCoreStuckTime", 0))
{
FreezeDetectorRunnable *fdr = new FreezeDetectorRunnable();
fdr->SetDelayTime(freeze_delay*1000);
ACE_Based::Thread freeze_thread(fdr);
freeze_thread.setPriority(ACE_Based::Highest);
}
///- Launch the world listener socket
uint16 wsport = sWorld->getIntConfig(CONFIG_PORT_WORLD);
std::string bind_ip = sConfig->GetStringDefault("BindIP", "0.0.0.0");
if (sWorldSocketMgr->StartNetwork(wsport, bind_ip.c_str ()) == -1)
{
sLog->outError ("Failed to start network");
World::StopNow(ERROR_EXIT_CODE);
// go down and shutdown the server
}
// set server online (allow connecting now)
LoginDatabase.DirectPExecute("UPDATE realmlist SET color = color & ~%u, population = 0 WHERE id = '%u'", REALM_FLAG_INVALID, realmID);
sWorldSocketMgr->Wait();
if (soap_thread)
{
soap_thread->wait();
soap_thread->destroy();
delete soap_thread;
}
// set server offline
LoginDatabase.PExecute("UPDATE realmlist SET color = color | %u WHERE id = '%d'", REALM_FLAG_OFFLINE, realmID);
// when the main thread closes the singletons get unloaded
示例7: CreatePIDFile
//.........这里部分代码省略.........
if (!curAff)
{
sLog.outError("Processors marked in UseProcessors bitmask (hex) %x not accessible for mangosd. Accessible processors bitmask (hex): %x", Aff, appAff);
}
else
{
if (SetProcessAffinityMask(hProcess, curAff))
sLog.outString("Using processors (bitmask, hex): %x", curAff);
else
sLog.outError("Can't set used processors (hex): %x", curAff);
}
}
sLog.outString();
}
bool Prio = sConfig.GetBoolDefault("ProcessPriority", false);
// if(Prio && (m_ServiceStatus == -1)/* need set to default process priority class in service mode*/)
if (Prio)
{
if (SetPriorityClass(hProcess, HIGH_PRIORITY_CLASS))
sLog.outString("mangosd process priority class set to HIGH");
else
sLog.outError("Can't set mangosd process priority class.");
sLog.outString();
}
}
#endif
///- Start up freeze catcher thread
MaNGOS::Thread* freeze_thread = nullptr;
if (uint32 freeze_delay = sConfig.GetIntDefault("MaxCoreStuckTime", 0))
{
FreezeDetectorRunnable* fdr = new FreezeDetectorRunnable();
fdr->SetDelayTime(freeze_delay * 1000);
freeze_thread = new MaNGOS::Thread(fdr);
freeze_thread->setPriority(MaNGOS::Priority_Highest);
}
{
int32 networkThreadWorker = sConfig.GetIntDefault("Network.Threads", 1);
if (networkThreadWorker <= 0)
{
sLog.outError("Invalid network tread workers setting in mangosd.conf. (%d) should be > 0", networkThreadWorker);
networkThreadWorker = 1;
}
MaNGOS::Listener<WorldSocket> listener(sConfig.GetStringDefault("BindIP", "0.0.0.0"), int32(sWorld.getConfig(CONFIG_UINT32_PORT_WORLD)), networkThreadWorker);
std::unique_ptr<MaNGOS::Listener<RASocket>> raListener;
if (sConfig.GetBoolDefault("Ra.Enable", false))
raListener.reset(new MaNGOS::Listener<RASocket>(sConfig.GetStringDefault("Ra.IP", "0.0.0.0"), sConfig.GetIntDefault("Ra.Port", 3443), 1));
std::unique_ptr<SOAPThread> soapThread;
if (sConfig.GetBoolDefault("SOAP.Enabled", false))
soapThread.reset(new SOAPThread(sConfig.GetStringDefault("SOAP.IP", "127.0.0.1"), sConfig.GetIntDefault("SOAP.Port", 7878)));
// wait for shut down and then let things go out of scope to close them down
while (!World::IsStopped())
std::this_thread::sleep_for(std::chrono::seconds(1));
}
///- Stop freeze protection before shutdown tasks
if (freeze_thread)
{
freeze_thread->destroy();
delete freeze_thread;
示例8: __
int Master::Run()
{
sLog.outString(" ___ _ _ ___ ");
sLog.outString(" / _ \\ | |_ ___ _ __ (_) __ / __| ___ _ _ ___ ");
sLog.outString(" / /_\\ \\ | _| / _ \\ | ' \\ | | / _| | (__ / _ \\ | '_| / -_)");
sLog.outString("/_/ \\_\\ \\__| \\___/ |_|_|_| |_| \\__| \\___| \\___/ |_| \\___|");
sLog.outString("");
std::string pidfile = sConfig.GetStringDefault("PidFile", "");
if (!pidfile.empty())
{
uint32 pid = CreatePIDFile(pidfile);
if (!pid)
{
sLog.outError("Cannot create PID file %s.\n", pidfile.c_str());
return 1;
}
sLog.outString("Daemon PID: %u\n", pid);
}
if (!_StartDB())
return 1;
sWorld.SetInitialWorldSettings();
_HookSignals();
ACE_Based::Thread world_thread(new WorldRunnable);
world_thread.setPriority(ACE_Based::Highest);
std::string builds = AcceptableClientBuildsListStr();
LoginDatabase.escape_string(builds);
LoginDatabase.PExecute("UPDATE realmlist SET flag = flag & ~(%u), population = 0, gamebuild = '%s' WHERE id = '%d'", REALM_FLAG_OFFLINE, builds.c_str(), realmID);
ACE_Based::Thread* cliThread = NULL;
#ifdef _WIN32
if (sConfig.GetBoolDefault("Console.Enable", true) && (m_ServiceStatus == -1))
#else
if (sConfig.GetBoolDefault("Console.Enable", true))
#endif
{
cliThread = new ACE_Based::Thread(new CliRunnable);
}
ACE_Based::Thread rar_thread(new RARunnable);
#ifdef _WIN32
{
HANDLE hProcess = GetCurrentProcess();
uint32 Aff = sConfig.GetIntDefault("UseProcessors", 0);
if (Aff > 0)
{
ULONG_PTR appAff;
ULONG_PTR sysAff;
if (GetProcessAffinityMask(hProcess,&appAff,&sysAff))
{
ULONG_PTR curAff = Aff & appAff;
if (!curAff)
{
sLog.outError("Processors marked in UseProcessors bitmask (hex) %x not accessible for OregonCore. Accessible processors bitmask (hex): %x",Aff,appAff);
}
else
{
if (SetProcessAffinityMask(hProcess,curAff))
sLog.outString("Using processors (bitmask, hex): %x", curAff);
else
sLog.outError("Can't set used processors (hex): %x",curAff);
}
}
sLog.outString();
}
bool Prio = sConfig.GetBoolDefault("ProcessPriority", false);
if (Prio)
{
if (SetPriorityClass(hProcess,HIGH_PRIORITY_CLASS))
sLog.outString("OregonCore process priority class set to HIGH");
else
sLog.outError("ERROR: Can't set OregonCore process priority class.");
sLog.outString();
}
}
#endif
ACE_Based::Thread* soap_thread = NULL;
if (sConfig.GetBoolDefault("SOAP.Enabled", false))
{
OCSoapRunnable* soapconnectector = new OCSoapRunnable();
soapconnectector->setListenArguments(sConfig.GetStringDefault("SOAP.IP", "127.0.0.1"), uint16(sConfig.GetIntDefault("SOAP.Port", 7878)));
soap_thread = new ACE_Based::Thread(soapconnectector);
}
ACE_Based::Thread* freeze_thread = NULL;
if (uint32 freeze_delay = sConfig.GetIntDefault("MaxCoreStuckTime", 0))
{
FreezeDetectorRunnable *fdr = new FreezeDetectorRunnable();
fdr->SetDelayTime(freeze_delay*1000);
//.........这里部分代码省略.........