本文整理汇总了C++中IntervalTimer::Passed方法的典型用法代码示例。如果您正苦于以下问题:C++ IntervalTimer::Passed方法的具体用法?C++ IntervalTimer::Passed怎么用?C++ IntervalTimer::Passed使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类IntervalTimer
的用法示例。
在下文中一共展示了IntervalTimer::Passed方法的3个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。
示例1: OnUpdate
void OnUpdate(uint32 diff) {
m_rewardTimer.Update(diff);
if(m_rewardTimer.Passed())
{
m_rewardTimer.Reset();
sendRewards();
}
}
示例2: OnUpdate
void OnUpdate(uint32 diff)
{
if (!ExternalMail)
return;
if (extmail_timer.GetCurrent() >= 0)
extmail_timer.Update(diff);
else
extmail_timer.SetCurrent(0);
if (extmail_timer.Passed())
{
extmail_timer.Reset();
SendExternalMails();
}
}
示例3: main
//.........这里部分代码省略.........
bool Prio = sConfig.GetBoolDefault("ProcessPriority", false);
if(Prio)
{
if(SetPriorityClass(hProcess,HIGH_PRIORITY_CLASS))
sLog.outString("realmd process priority class set to HIGH");
else
sLog.outError("Can't set realmd process priority class.");
sLog.outString();
}
}
#endif
//server has started up successfully => enable async DB requests
LoginDatabase.AllowAsyncTransactions();
// maximum counter for next ping
uint32 numLoops = (sConfig.GetIntDefault( "MaxPingTime", 30 ) * (MINUTE * 1000000 / 100000));
uint32 loopCounter = 0;
uint32 last_ping_time = 0;
uint32 now = WorldTimer::getMSTime();
uint32 diff;
uint32 lasttime = now;
uint32 last_ipprops_cleanup = 0;
///- Wait for termination signal
while (!stopEvent)
{
// dont move this outside the loop, the reactor will modify it
ACE_Time_Value interval(0, 100000);
if (ACE_Reactor::instance()->run_reactor_event_loop(interval) == -1)
break;
now = WorldTimer::getMSTime();
diff = WorldTimer::getMSTimeDiff(lasttime, now);
lasttime = now;
badPointsTimer.Update(diff);
if( (++loopCounter) == numLoops )
{
// FG: protect against network system overloading
// if that happens, force realmd close (autorestarter ftw!)
if(WorldTimer::getMSTimeDiff(last_ping_time, now) < 10000)
{
sLog.outError("NETWORK SYSTEM OVERLOAD");
raise(SIGSEGV); // force close
abort();
}
last_ping_time = now;
loopCounter = 0;
DETAIL_LOG("Ping MySQL to keep connection alive");
LoginDatabase.Ping();
}
// FG: clear flood protect buffer periodically
if(WorldTimer::getMSTimeDiff(last_ipprops_cleanup, now) > 30000) // flush stored IPs every 30 secs
{
last_ipprops_cleanup = now;
uint32 flushed = 0, blocked = 0, stored = 0;
CleanupIPPropmap(flushed, blocked, stored);
sLog.outDetail("IPProp: Flushed %u total, %u of them blocked, now %u stored", flushed, blocked, stored);
}
// FG: handle "bad points" drop
if(badPointsTimer.Passed())
{
badPointsTimer.Reset();
if(badPointsDropAmount)
{
uint64 goodtime = uint64(time(NULL)) - badPointsDropWaitTime;
LoginDatabase.Execute("UPDATE account_badpoints SET maxpts = curpts WHERE maxpts < curpts");
LoginDatabase.PExecute("UPDATE account_badpoints SET curpts = 0 WHERE curpts <= %u AND lasttime < "UI64FMTD,
badPointsDropAmount, goodtime);
LoginDatabase.PExecute("UPDATE account_badpoints SET curpts = curpts - %u WHERE curpts > %u AND lasttime < "UI64FMTD,
badPointsDropAmount, badPointsDropAmount, goodtime);
}
}
#ifdef WIN32
if (m_ServiceStatus == 0) stopEvent = true;
while (m_ServiceStatus == 2) Sleep(1000);
#endif
}
///- Wait for the delay thread to exit
LoginDatabase.HaltDelayThread();
///- Remove signal handling before leaving
UnhookSignals();
sLog.outString( "Halting process..." );
return 0;
}