VirtualBox

Changeset 48822 in vbox


Ignore:
Timestamp:
Oct 2, 2013 3:22:41 PM (11 years ago)
Author:
vboxsync
Message:

FE/Qt: UI thread-pool: Make sure thread survive full timeout if concurrent thread steal his task.

File:
1 edited

Legend:

Unmodified
Added
Removed
  • trunk/src/VBox/Frontends/VirtualBox/src/globals/UIThreadPool.cpp

    r48534 r48822  
    150150    m_taskLocker.lock();
    151151
    152     /* Try to get task (moving it from queue to processing list): */
     152    /* Try to dequeue task: */
    153153    if (!m_tasks.isEmpty())
    154154        pTask = m_tasks.dequeue();
    155155
    156     /* If there is no task currently: */
    157     if (!pTask)
     156    /* Make sure we have a task or outdated: */
     157    bool fOutdated = false;
     158    while (!pTask && !fOutdated)
    158159    {
    159160        /* Mark thread as not busy: */
     
    162163        /* Wait for <m_uIdleTimeout> milli-seconds for the next task,
    163164         * this issue will temporary unlock <m_taskLocker>: */
    164         m_taskCondition.wait(&m_taskLocker, m_uIdleTimeout);
     165        fOutdated = !m_taskCondition.wait(&m_taskLocker, m_uIdleTimeout);
    165166
    166167        /* Mark thread as busy again: */
    167168        pWorker->setBusy(true);
    168169
    169         /* Try to get task again (moving it from queue to processing list): */
     170        /* Try to dequeue task again: */
    170171        if (!m_tasks.isEmpty())
    171172            pTask = m_tasks.dequeue();
    172173    }
     174    Assert(pTask || fOutdated);
    173175
    174176    /* Unlock task locker: */
Note: See TracChangeset for help on using the changeset viewer.

© 2024 Oracle Support Privacy / Do Not Sell My Info Terms of Use Trademark Policy Automated Access Etiquette