本文整理汇总了C++中ace_based::Thread::kill方法的典型用法代码示例。如果您正苦于以下问题:C++ Thread::kill方法的具体用法?C++ Thread::kill怎么用?C++ Thread::kill使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类ace_based::Thread
的用法示例。
在下文中一共展示了Thread::kill方法的1个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。
示例1: Run
//.........这里部分代码省略.........
}
}
#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();
// Stop soap thread
if (soap_thread)
{
soap_thread->wait();
delete soap_thread;
}
// Set server offline in realmlist
LoginDatabase.PExecute("UPDATE realmlist SET realmflags = realmflags | %u WHERE id = '%d'", REALM_FLAG_OFFLINE, realmID);
// when the main thread closes the singletons get unloaded
// since worldrunnable uses them, it will crash if unloaded after master
rar_thread.wait ();
// Clean account database before leaving
clearOnlineAccounts();
// Wait for delay threads to end
CharacterDatabase.HaltDelayThread();
WorldDatabase.HaltDelayThread();
LoginDatabase.HaltDelayThread();
sLog.outString("Halting process...");
if (cliThread)
{
cliThread->kill(SIGINT);
cliThread->wait();
delete cliThread;
}
// we've been messing up with stderr (if Console.Enable was set),
// so we need to restore it back, to prevent SIGPIPEs after restart
dup2(defaultStderr, 2);
close(defaultStderr);
// Remove signal handling before leaving
_UnhookSignals();
// for some unknown reason, unloading scripts here and not in worldrunnable
// fixes a memory leak related to detaching threads from the module
//UnloadScriptingModule();
// Exit the process with specified return value
return World::GetExitCode();
}