本文整理汇总了C++中TimedEvent::set_time方法的典型用法代码示例。如果您正苦于以下问题:C++ TimedEvent::set_time方法的具体用法?C++ TimedEvent::set_time怎么用?C++ TimedEvent::set_time使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类TimedEvent
的用法示例。
在下文中一共展示了TimedEvent::set_time方法的1个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。
示例1: call_timer
/* Call timed event at front of queue, whose time is <= `now'.
* Returns true if an event handler was called. (false if time isn't up yet)
*/
bool TimeQueue::call_timer(uint32 now)
{
if(empty())
return(false);
TimedEvent *tevent = tq.front();
if(tevent->defunct)
{
assert(pop_timer() == tevent);
delete_timer(tevent);
return(false);
}
if(tevent->time > now)
return(false);
//dequeue event here
pop_timer(); // remove timer in case we have recursion in the timed() call.
tevent->timed(now); // fire
//re-queue if repeating timer.
if(tevent->repeat_count != 0) // repeat! same delay, add time
{
// use updated time so it isn't repeated too soon
tevent->set_time();
// tevent->time = clock->get_ticks() + tevent->delay;
// tevent->time = now + tevent->delay;
add_timer(tevent);
if(tevent->repeat_count > 0) // don't reduce count if infinite (-1)
--tevent->repeat_count;
}
else
delete_timer(tevent); // if not repeated, safe to delete
return(true);
}