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 c25bc0c046d176eb4221dc2acb42563b62eb9454
Author:     Caolán McNamara <caolan.mcnam...@collabora.com>
AuthorDate: Thu Jun 13 12:59:09 2024 +0100
Commit:     Caolán McNamara <caolan.mcnam...@collabora.com>
CommitDate: Fri Aug 23 21:52:45 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 <michael.me...@collabora.com>
    Tested-by: Jenkins CollaboraOffice <jenkinscollaboraoff...@gmail.com>
    (cherry picked from commit c7ff8768db58aaee5ce0acbabe97faeaf450f017)
    Reviewed-on: https://gerrit.libreoffice.org/c/core/+/172329
    Reviewed-by: Caolán McNamara <caolan.mcnam...@collabora.com>
    Tested-by: Jenkins

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 f06cffe5eaae..1a9fc79e621d 100644
--- a/desktop/source/lib/init.cxx
+++ b/desktop/source/lib/init.cxx
@@ -3441,7 +3441,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 0b2ebc8ac9e6..c5cc92944da9 100644
--- a/include/comphelper/threadpool.hxx
+++ b/include/comphelper/threadpool.hxx
@@ -76,7 +76,8 @@ public:
                              );
 
     /// 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; 
};

Reply via email to