[Libreoffice-commits] core.git: Branch 'feature/perfwork4' - comphelper/source

Matúš Kukan matus.kukan at collabora.com
Tue Nov 4 04:18:05 PST 2014


 comphelper/source/misc/threadpool.cxx |    4 ++++
 1 file changed, 4 insertions(+)

New commits:
commit 2ac7d5038806b017c8dc062c1ba29930649cc3db
Author: Matúš Kukan <matus.kukan at collabora.com>
Date:   Tue Nov 4 13:08:28 2014 +0100

    thread-pool: Avoid deadlock when there are no working threads
    
    maTasksComplete.wait() would never finish because there are no threads
    working and thus ThreadPool::stopWork() won't be called.
    
    Change-Id: I7103bdb779eb66a65cd8496091e72a0c65eb3567

diff --git a/comphelper/source/misc/threadpool.cxx b/comphelper/source/misc/threadpool.cxx
index 3717ffb..39c4e73 100644
--- a/comphelper/source/misc/threadpool.cxx
+++ b/comphelper/source/misc/threadpool.cxx
@@ -187,6 +187,10 @@ void ThreadPool::waitUntilEmpty()
 {
     osl::ResettableMutexGuard aGuard( maGuard );
 
+    // Avoid deadlock when there are no working threads
+    if( maTasks.empty() )
+        return;
+
     if( maWorkers.empty() )
     { // no threads at all -> execute the work in-line
         ThreadTask *pTask;


More information about the Libreoffice-commits mailing list