本文整理汇总了C++中Timer::GetNextExecution方法的典型用法代码示例。如果您正苦于以下问题:C++ Timer::GetNextExecution方法的具体用法?C++ Timer::GetNextExecution怎么用?C++ Timer::GetNextExecution使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类Timer
的用法示例。
在下文中一共展示了Timer::GetNextExecution方法的2个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。
示例1: Execute
void Timers::Execute()
{
timeval curTime;
gettimeofday(&curTime, 0);
for (Timer* s = m_firstTimer; s != 0; s = m_firstTimer)
{
if (CompareTimevals(s->GetNextExecution(), curTime))
break;
TimerCbk_t cbk = s->GetCallback();
void* userdata = s->GetUserdata();
s->Update();
int remainingReps = s->GetRemainingRepetitions();
cbk(userdata);
if (FindTimer(s))
{
DeleteFromList(s);
if (remainingReps == 0)
delete s;
else
InsertTimer(s);
}
}
}
示例2: InsertTimer
void Timers::InsertTimer(Timer* timer)
{
if (!m_firstTimer)
{
m_firstTimer = timer;
m_lastTimer = timer;
}
else
{
Timer* s;
Timer* s2 = 0;
const timeval& tv = timer->GetNextExecution();
for (s = m_firstTimer; s != 0; s = s->next)
{
if (CompareTimevals(s->GetNextExecution(), tv))
break;
s2 = s;
}
if (!s2)
{
/* First timer to be executed */
m_firstTimer->prev = timer;
timer->next = m_firstTimer;
m_firstTimer = timer;
}
else if (!s)
{
/* Last timer to be executed */
m_lastTimer->next = timer;
timer->prev = m_lastTimer;
m_lastTimer = timer;
}
else
{
/* Intermediate */
s2->next = timer;
s->prev = timer;
timer->next = s;
timer->prev = s2;
}
}
}