mirror of
https://bitbucket.org/smil3y/kdelibs.git
synced 2025-02-23 10:22:48 +00:00
kdecore: start as many threads as possible from the queue of KThreadPool
Signed-off-by: Ivailo Monev <xakepa10@gmail.com>
This commit is contained in:
parent
f53d175e6b
commit
9d2994fad0
1 changed files with 5 additions and 5 deletions
|
@ -59,7 +59,8 @@ void KThreadPoolPrivate::appendThread(QThread *thread)
|
|||
activethreads.append(thread);
|
||||
parent->connect(
|
||||
thread, SIGNAL(finished()),
|
||||
parent, SLOT(_k_slotFinished())
|
||||
parent, SLOT(_k_slotFinished()),
|
||||
Qt::QueuedConnection
|
||||
);
|
||||
}
|
||||
|
||||
|
@ -77,13 +78,13 @@ void KThreadPoolPrivate::_k_slotFinished()
|
|||
thread->deleteLater();
|
||||
}
|
||||
}
|
||||
if (!queuedthreads.isEmpty()) {
|
||||
while (activethreadcount < maxthreads && !queuedthreads.isEmpty()) {
|
||||
QThread* thread = queuedthreads.takeFirst();
|
||||
kDebug() << "starting thread from queue" << thread;
|
||||
appendThread(thread);
|
||||
locker.unlock();
|
||||
thread->start();
|
||||
}
|
||||
kDebug() << "currently" << activethreadcount << "active threads";
|
||||
}
|
||||
|
||||
|
||||
|
@ -108,7 +109,6 @@ void KThreadPool::start(QThread *thread, const QThread::Priority priority)
|
|||
} else {
|
||||
kDebug() << "starting thread" << thread;
|
||||
d->appendThread(thread);
|
||||
locker.unlock();
|
||||
thread->start(priority);
|
||||
}
|
||||
}
|
||||
|
@ -120,7 +120,7 @@ void KThreadPool::waitForDone(const int timeout)
|
|||
QElapsedTimer elapsedtimer;
|
||||
elapsedtimer.start();
|
||||
QMutableListIterator<QThread*> iter(d->activethreads);
|
||||
kDebug() << "currently" << d->activethreads << "active threads";
|
||||
kDebug() << "currently" << d->activethreadcount << "active threads";
|
||||
while ((timeout < 1 || elapsedtimer.elapsed() < timeout) && d->activethreadcount > 0) {
|
||||
iter.toFront();
|
||||
while (iter.hasNext()) {
|
||||
|
|
Loading…
Add table
Reference in a new issue