Exemple #1
0
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();
}
Exemple #2
0
void TimerBase::collectFiringTimers(double fireTime, Vector<TimerBase*>& firingTimers)
{
    while (!timerHeap->isEmpty() && timerHeap->first()->m_nextFireTime <= fireTime) {
        TimerBase* timer = timerHeap->first();
        firingTimers.append(timer);
        timersReadyToFire->add(timer);
        timer->m_nextFireTime = 0;
        timer->heapDeleteMin();
    }
}