本文整理汇总了C++中TimedEvent::DecRef方法的典型用法代码示例。如果您正苦于以下问题:C++ TimedEvent::DecRef方法的具体用法?C++ TimedEvent::DecRef怎么用?C++ TimedEvent::DecRef使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类TimedEvent
的用法示例。
在下文中一共展示了TimedEvent::DecRef方法的1个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。
示例1: Update
void EventableObjectHolder::Update(time_t time_difference)
{
m_lock.Acquire(); // <<<<
/* Insert any pending objects in the insert pool. */
m_insertPoolLock.Acquire();
InsertableQueue::iterator iqi;
InsertableQueue::iterator iq2 = m_insertPool.begin();
while(iq2 != m_insertPool.end())
{
iqi = iq2++;
if((*iqi)->deleted || (*iqi)->instanceId != mInstanceId)
(*iqi)->DecRef();
else
m_events.push_back( (*iqi) );
m_insertPool.erase(iqi);
}
m_insertPoolLock.Release();
/* Now we can proceed normally. */
EventList::iterator itr = m_events.begin();
EventList::iterator it2;
TimedEvent * ev;
while(itr != m_events.end())
{
it2 = itr++;
if((*it2)->instanceId != mInstanceId || (*it2)->deleted ||
( mInstanceId == WORLD_INSTANCE && (*it2)->eventFlag & EVENT_FLAG_DO_NOT_EXECUTE_IN_WORLD_CONTEXT))
{
// remove from this list.
(*it2)->DecRef();
m_events.erase(it2);
continue;
}
// Event Update Procedure
ev = *it2;
if((uint32)ev->currTime <= time_difference)
{
// execute the callback
if(ev->eventFlag & EVENT_FLAG_DELETES_OBJECT)
{
ev->deleted = true;
ev->cb->execute();
m_events.erase(it2);
ev->DecRef();
continue;
}
else
ev->cb->execute();
// check if the event is expired now.
if(ev->repeats && --ev->repeats == 0)
{
// Event expired :>
/* remove the event from the object */
/*obj = (EventableObject*)ev->obj;
obj->event_RemoveByPointer(ev);*/
/* remove the event from here */
ev->deleted = true;
ev->DecRef();
m_events.erase(it2);
continue;
}
else if(ev->deleted)
{
// event is now deleted
ev->DecRef(); //this was added on "addevent"
m_events.erase(it2);
continue;
}
// event has to repeat again, reset the timer
ev->currTime = ev->msTime;
}
else
{
// event is still "waiting", subtract time difference
ev->currTime -= time_difference;
}
}
m_lock.Release();
}