Ejemplo n.º 1
0
void ThreadTimers::sharedTimerFiredInternal()
{
    ASSERT(isMainThread() || (!isWebThread() && !isUIThread()));
    // 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 ThreadGlobalData::setWebCoreThreadData()
{
    ASSERT(isWebThread());
    ASSERT(&threadGlobalData() != ThreadGlobalData::sharedMainThreadStaticData);

    // Set WebThread's ThreadGlobalData object to be the same as the main UI thread.
    ThreadGlobalData::staticData->replace(ThreadGlobalData::sharedMainThreadStaticData);

    ASSERT(&threadGlobalData() == ThreadGlobalData::sharedMainThreadStaticData);
}
Ejemplo n.º 3
0
WTFThreadData::WTFThreadData()
    : m_atomicStringTable(0)
    , m_atomicStringTableDestructor(0)
#if USE(JSC)
    , m_stackBounds(StackBounds::currentThreadStackBounds())
#endif
{
#if USE(JSC)
    static TI::IdentifierTable* sharedIdentifierTable = new TI::IdentifierTable();
    if (pthread_main_np() || isWebThread())
        m_defaultIdentifierTable = sharedIdentifierTable;
    else
        m_defaultIdentifierTable = new TI::IdentifierTable();

    m_currentIdentifierTable = m_defaultIdentifierTable;
#endif
}
Ejemplo n.º 4
0
void AtomicStringTable::create(WTFThreadData& data)
{
#if USE(WEB_THREAD)
    // On iOS, one AtomicStringTable is shared between the main UI thread and the WebThread.
    static AtomicStringTable* sharedStringTable = new AtomicStringTable;

    bool currentThreadIsWebThread = isWebThread();
    if (currentThreadIsWebThread || isUIThread())
        data.m_atomicStringTable = sharedStringTable;
    else
        data.m_atomicStringTable = new AtomicStringTable;

    // We do the following so that its destruction happens only
    // once - on the main UI thread.
    if (!currentThreadIsWebThread)
        data.m_atomicStringTableDestructor = AtomicStringTable::destroy;
#else
    data.m_atomicStringTable = new AtomicStringTable;
    data.m_atomicStringTableDestructor = AtomicStringTable::destroy;
#endif // USE(WEB_THREAD)
}