summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--comphelper/source/misc/threadpool.cxx7
-rw-r--r--include/comphelper/threadpool.hxx7
-rw-r--r--sc/source/filter/oox/workbookfragment.cxx5
3 files changed, 11 insertions, 8 deletions
diff --git a/comphelper/source/misc/threadpool.cxx b/comphelper/source/misc/threadpool.cxx
index d2101ada54d2..236a314019f8 100644
--- a/comphelper/source/misc/threadpool.cxx
+++ b/comphelper/source/misc/threadpool.cxx
@@ -92,7 +92,7 @@ ThreadPool::ThreadPool( sal_Int32 nWorkers ) :
ThreadPool::~ThreadPool()
{
- waitUntilWorkersDone();
+ waitAndCleanupWorkers();
}
struct ThreadPoolStatic : public rtl::StaticWithInit< boost::shared_ptr< ThreadPool >,
@@ -109,9 +109,7 @@ ThreadPool& ThreadPool::getSharedOptimalPool()
return *ThreadPoolStatic::get().get();
}
-/// wait until all the workers have completed and
-/// terminate all threads
-void ThreadPool::waitUntilWorkersDone()
+void ThreadPool::waitAndCleanupWorkers()
{
waitUntilEmpty();
@@ -169,7 +167,6 @@ void ThreadPool::waitUntilEmpty()
pTask->doWork();
delete pTask;
}
- mbTerminate = true;
}
else
{
diff --git a/include/comphelper/threadpool.hxx b/include/comphelper/threadpool.hxx
index ae103f1164f1..2e5171902f55 100644
--- a/include/comphelper/threadpool.hxx
+++ b/include/comphelper/threadpool.hxx
@@ -39,14 +39,19 @@ public:
ThreadPool( sal_Int32 nWorkers );
virtual ~ThreadPool();
+ /// push a new task onto the work queue
void pushTask( ThreadTask *pTask /* takes ownership */ );
+
+ /// wait until all queued tasks are completed
void waitUntilEmpty();
- void waitUntilWorkersDone();
private:
class ThreadWorker;
friend class ThreadWorker;
+ /// wait until all work is completed, then join all threads
+ void waitAndCleanupWorkers();
+
ThreadTask *waitForWork( osl::Condition &rNewWork );
ThreadTask *popWork();
diff --git a/sc/source/filter/oox/workbookfragment.cxx b/sc/source/filter/oox/workbookfragment.cxx
index 62ea5bb415e1..8488b46de7e5 100644
--- a/sc/source/filter/oox/workbookfragment.cxx
+++ b/sc/source/filter/oox/workbookfragment.cxx
@@ -336,8 +336,9 @@ void importSheetFragments( WorkbookFragment& rWorkbookHandler, SheetFragmentVect
// bar updating.
Application::Yield();
}
- // join all the threads:
- aPool.waitUntilWorkersDone();
+ aPool.waitUntilEmpty();
+
+ // threads joined in ThreadPool destructor
}
else // single threaded iteration
{