void ThreadTimers::sharedTimerFiredInternal() { // Do a re-entrancy check. if (m_firingTimers) return; m_firingTimers = true; m_pendingSharedTimerFireTime = 0; double fireTime = monotonicallyIncreasingTime(); double timeToQuit = fireTime + maxDurationOfFiringTimers; while (!m_timerHeap.isEmpty() && m_timerHeap.first()->m_nextFireTime <= fireTime) { TimerBase* timer = m_timerHeap.first(); timer->m_nextFireTime = 0; timer->m_unalignedNextFireTime = 0; timer->heapDeleteMin(); double interval = timer->repeatInterval(); timer->setNextFireTime(interval ? fireTime + interval : 0); // Once the timer has been fired, it may be deleted, so do nothing else with it after this point. timer->fired(); // Catch the case where the timer asked timers to fire in a nested event loop, or we are over time limit. if (!m_firingTimers || timeToQuit < monotonicallyIncreasingTime()) break; } m_firingTimers = false; updateSharedTimer(); }
void RunLoop::TimerBase::timerFired(CFRunLoopTimerRef, void* context) { TimerBase* timer = static_cast<TimerBase*>(context); AutodrainedPool pool; timer->fired(); }
void RunLoop::TimerBase::timerFired(RunLoop* runLoop, uint64_t ID) { TimerMap::iterator it = runLoop->m_activeTimers.find(ID); ASSERT(it != runLoop->m_activeTimers.end()); TimerBase* timer = it->second; // FIMXE: Support repeating timers. ::KillTimer(runLoop->m_runLoopMessageWindow, ID); timer->fired(); }
void RunLoop::TimerBase::timerFired(RunLoop* runLoop, uint64_t ID) { TimerMap::iterator it = runLoop->m_activeTimers.find(ID); ASSERT(it != runLoop->m_activeTimers.end()); TimerBase* timer = it->second; if (!timer->m_isRepeating) { runLoop->m_activeTimers.remove(it); ::KillTimer(runLoop->m_runLoopMessageWindow, ID); } timer->fired(); }
void RunLoop::TimerBase::timerFired(RunLoop* runLoop, uint64_t ID) { TimerMap::iterator it = runLoop->m_activeTimers.find(ID); if (it == runLoop->m_activeTimers.end()) { // The timer must have been stopped after the WM_TIMER message was posted to the message queue. return; } TimerBase* timer = it->value; if (!timer->m_isRepeating) { runLoop->m_activeTimers.remove(it); ::KillTimer(runLoop->m_runLoopMessageWindow, ID); } timer->fired(); }
void TimerBase::fireTimers(double fireTime, const Vector<TimerBase*>& firingTimers) { int size = firingTimers.size(); for (int i = 0; i != size; ++i) { TimerBase* timer = firingTimers[i]; // If not in the set, this timer has been deleted or re-scheduled in another timer's fired function. // So either we don't want to fire it at all or we will fire it next time the shared timer goes off. // It might even have been deleted; that's OK because we won't do anything else with the pointer. if (!timersReadyToFire->contains(timer)) continue; // Setting the next fire time has a side effect of removing the timer from the firing timers set. double interval = timer->repeatInterval(); timer->setNextFireTime(interval ? fireTime + interval : 0); // Once the timer has been fired, it may be deleted, so do nothing else with it after this point. timer->fired(); // Catch the case where the timer asked timers to fire in a nested event loop. if (!timersReadyToFire) break; } }