diff options
author | Dennis Francis <dennis.francis@collabora.com> | 2019-03-20 20:07:58 +0530 |
---|---|---|
committer | Michael Meeks <michael.meeks@collabora.com> | 2019-03-21 11:24:26 +0100 |
commit | 769832cc1f592b1d0c39cda7795fe4548fc97566 (patch) | |
tree | 404546dfca76bc766ad88fcf9fe8f3cb5f7ad3f1 /comphelper/source/misc | |
parent | 3d9f973e6648c5819608237f390df523b6a32ed8 (diff) |
Increase the life-cycle of threads in thread-pool...
to ScDocument lifetime if possible. This helps to avoid lots
of thread setup-cost while doing recalcs especially if there are
many formula-groups in the document and most of them are fairly
light-weight.
Change-Id: Idd57e1ebd0d4e492f99e31237d4a55ec9c95a121
Reviewed-on: https://gerrit.libreoffice.org/69473
Tested-by: Jenkins
Reviewed-by: Michael Meeks <michael.meeks@collabora.com>
Diffstat (limited to 'comphelper/source/misc')
-rw-r--r-- | comphelper/source/misc/threadpool.cxx | 16 |
1 files changed, 10 insertions, 6 deletions
diff --git a/comphelper/source/misc/threadpool.cxx b/comphelper/source/misc/threadpool.cxx index d0178e9aa9a7..89d80298432b 100644 --- a/comphelper/source/misc/threadpool.cxx +++ b/comphelper/source/misc/threadpool.cxx @@ -213,7 +213,7 @@ std::unique_ptr<ThreadTask> ThreadPool::popWorkLocked( std::unique_lock< std::mu return nullptr; } -void ThreadPool::waitUntilDone(const std::shared_ptr<ThreadTaskTag>& rTag) +void ThreadPool::waitUntilDone(const std::shared_ptr<ThreadTaskTag>& rTag, bool bJoinAll) { #if defined DBG_UTIL && (defined LINUX || defined _WIN32) assert(!gbIsWorkerThread && "cannot wait for tasks from inside a task"); @@ -232,12 +232,16 @@ void ThreadPool::waitUntilDone(const std::shared_ptr<ThreadTaskTag>& rTag) rTag->waitUntilDone(); + if (bJoinAll) + joinAll(); +} + +void ThreadPool::joinAll() +{ + std::unique_lock< std::mutex > aGuard( maMutex ); + if (maTasks.empty()) // check if there are still tasks from another tag { - std::unique_lock< std::mutex > aGuard( maMutex ); - if (maTasks.empty()) // check if there are still tasks from another tag - { - shutdownLocked(aGuard); - } + shutdownLocked(aGuard); } } |