comphelper/source/misc/threadpool.cxx | 4 +++- desktop/source/lib/init.cxx | 3 ++- include/comphelper/threadpool.hxx | 3 ++- 3 files changed, 7 insertions(+), 3 deletions(-)
New commits: commit c7ff8768db58aaee5ce0acbabe97faeaf450f017 Author: Caolán McNamara <[email protected]> AuthorDate: Thu Jun 13 12:59:09 2024 +0100 Commit: Andras Timar <[email protected]> CommitDate: Mon Jun 24 17:07:05 2024 +0200 make joinThreadsIfIdle return false if it cannot join Change-Id: I52e22bf5e68809d6787d2d135b6a35384cf79391 Reviewed-on: https://gerrit.libreoffice.org/c/core/+/168785 Reviewed-by: Michael Meeks <[email protected]> Tested-by: Jenkins CollaboraOffice <[email protected]> diff --git a/comphelper/source/misc/threadpool.cxx b/comphelper/source/misc/threadpool.cxx index f0a71eb05168..9f13dbe34f91 100644 --- a/comphelper/source/misc/threadpool.cxx +++ b/comphelper/source/misc/threadpool.cxx @@ -289,13 +289,15 @@ void ThreadPool::waitUntilDone(const std::shared_ptr<ThreadTaskTag>& rTag, bool joinThreadsIfIdle(); } -void ThreadPool::joinThreadsIfIdle() +bool ThreadPool::joinThreadsIfIdle() { std::unique_lock< std::mutex > aGuard( maMutex ); if (isIdle()) // check if there are still tasks from another tag { shutdownLocked(aGuard); + return true; } + return false; } std::shared_ptr<ThreadTaskTag> ThreadPool::createThreadTaskTag() diff --git a/desktop/source/lib/init.cxx b/desktop/source/lib/init.cxx index ee2ac3508b08..a17a1ea9d447 100644 --- a/desktop/source/lib/init.cxx +++ b/desktop/source/lib/init.cxx @@ -3392,7 +3392,8 @@ static void lo_stopURP(LibreOfficeKit* /* pThis */, static int lo_joinThreads(LibreOfficeKit* /* pThis */) { comphelper::ThreadPool &pool = comphelper::ThreadPool::getSharedOptimalPool(); - pool.joinThreadsIfIdle(); + if (!pool.joinThreadsIfIdle()) + return 0; // Grammar checker thread css::uno::Reference<css::linguistic2::XLinguServiceManager2> xLangSrv = diff --git a/include/comphelper/threadpool.hxx b/include/comphelper/threadpool.hxx index 84f9dc9284f6..cee9c2728ece 100644 --- a/include/comphelper/threadpool.hxx +++ b/include/comphelper/threadpool.hxx @@ -70,7 +70,8 @@ public: void waitUntilDone(const std::shared_ptr<ThreadTaskTag>&, bool bJoin = true); /// join all threads if there are no tasks presently. - void joinThreadsIfIdle(); + /// return false if !isIdle() + bool joinThreadsIfIdle(); /// return true if there are no queued or worked-on tasks bool isIdle() const { return maTasks.empty() && mnBusyWorkers == 0; };
