本文整理汇总了C++中ace_based::Thread::setPriority方法的典型用法代码示例。如果您正苦于以下问题:C++ Thread::setPriority方法的具体用法?C++ Thread::setPriority怎么用?C++ Thread::setPriority使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类ace_based::Thread
的用法示例。
在下文中一共展示了Thread::setPriority方法的1个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。
示例1: Run
/// Main function
int Master::Run()
{
OpenSSLCrypto::threadsSetup();
BigNumber seed1;
seed1.SetRand(16 * 8);
sLog->outString("%s (worldserver-daemon)", _FULLVERSION);
sLog->outString("<Ctrl-C> to stop.\n");
/// worldserver PID file creation
std::string pidFile = sConfigMgr->GetStringDefault("PidFile", "");
if (!pidFile.empty())
{
if (uint32 pid = CreatePIDFile(pidFile))
sLog->outString("Daemon PID: %u\n", pid);
else
{
sLog->outString("Cannot create PID file %s.\n", pidFile.c_str());
return 1;
}
}
///- Start the databases
if (!_StartDB())
return 1;
// set server offline (not connectable)
LoginDatabase.DirectPExecute("UPDATE realmlist SET flag = (flag & ~%u) | %u WHERE id = '%d'", REALM_FLAG_OFFLINE, REALM_FLAG_INVALID, realmID);
///- Initialize the World
sWorld->SetInitialWorldSettings();
///- Initialize the signal handlers
WorldServerSignalHandler signalINT, signalTERM; //, signalSEGV
#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
//handle.register_handler(SIGSEGV, &signalSEGV);
///- Launch WorldRunnable thread
ACE_Based::Thread worldThread(new WorldRunnable);
worldThread.setPriority(ACE_Based::Highest);
ACE_Based::Thread* cliThread = NULL;
#ifdef _WIN32
if (sConfigMgr->GetBoolDefault("Console.Enable", true) && (m_ServiceStatus == -1)/* need disable console in service mode*/)
#else
if (sConfigMgr->GetBoolDefault("Console.Enable", true))
#endif
{
///- Launch CliRunnable thread
cliThread = new ACE_Based::Thread(new CliRunnable);
}
ACE_Based::Thread rarThread(new RARunnable);
// pussywizard:
ACE_Based::Thread auctionLising_thread(new AuctionListingRunnable);
auctionLising_thread.setPriority(ACE_Based::High);
#if defined(_WIN32) || defined(__linux__)
///- Handle affinity for multiple processors and process priority
uint32 affinity = sConfigMgr->GetIntDefault("UseProcessors", 0);
bool highPriority = sConfigMgr->GetBoolDefault("ProcessPriority", false);
#ifdef _WIN32 // Windows
HANDLE hProcess = GetCurrentProcess();
if (affinity > 0)
{
ULONG_PTR appAff;
ULONG_PTR sysAff;
if (GetProcessAffinityMask(hProcess, &appAff, &sysAff))
{
ULONG_PTR currentAffinity = affinity & appAff; // remove non accessible processors
if (!currentAffinity)
sLog->outError("Processors marked in UseProcessors bitmask (hex) %x are not accessible for the worldserver. Accessible processors bitmask (hex): %x", affinity, appAff);
else if (SetProcessAffinityMask(hProcess, currentAffinity))
sLog->outString("Using processors (bitmask, hex): %x", currentAffinity);
else
sLog->outError("Can't set used processors (hex): %x", currentAffinity);
}
}
if (highPriority)
//.........这里部分代码省略.........