Beispiel #1
0
/*!
    \internal
    Makes all threads exit, waits for each tread to exit and deletes it.
*/
void QThreadPoolPrivate::reset()
{
    QMutexLocker locker(&mutex);
    isExiting = true;
    runnableReady.wakeAll();

    while (!allThreads.empty()) {
        // move the contents of the set out so that we can iterate without the lock
        QSet<QThreadPoolThread *> allThreadsCopy;
        allThreadsCopy.swap(allThreads);
        locker.unlock();

        foreach (QThreadPoolThread *thread, allThreadsCopy) {
            thread->wait();
            delete thread;
        }

        locker.relock();
        // repeat until all newly arrived threads have also completed
    }