From 075930ccd951cadcc83d30c5fc8c69e343ed70b8 Mon Sep 17 00:00:00 2001 From: Thiago Macieira Date: Mon, 19 Apr 2010 21:02:54 +0200 Subject: Don't rely on tryStart() to do job control. It may fail but threads become available the next instant. Instead, simply use our own currentLookups count. Reviewed-by: Markus Goetz --- src/network/kernel/qhostinfo.cpp | 6 ++---- 1 file changed, 2 insertions(+), 4 deletions(-) diff --git a/src/network/kernel/qhostinfo.cpp b/src/network/kernel/qhostinfo.cpp index 6894978..2dd6485 100644 --- a/src/network/kernel/qhostinfo.cpp +++ b/src/network/kernel/qhostinfo.cpp @@ -551,13 +551,11 @@ void QHostInfoLookupManager::work() } } - if (scheduled && threadPool.tryStart(scheduled)) { + if (scheduled && currentLookups.size() < threadPool.maxThreadCount()) { // runnable now running in new thread, track this in currentLookups + threadPool.start(scheduled); iterator.remove(); currentLookups.append(scheduled); - } else if (scheduled) { - // wanted to start, but could not because thread pool is busy - break; } else { // was postponed, continue iterating continue; -- cgit v0.12