drawinglayer/source/primitive2d/BufferedDecompositionFlusher.cxx  |   16 
++++++----
 include/drawinglayer/primitive2d/BufferedDecompositionFlusher.hxx |    2 +
 2 files changed, 13 insertions(+), 5 deletions(-)

New commits:
commit abfe481b065797bc97b073902009b9359cde9718
Author:     Noel Grandin <[email protected]>
AuthorDate: Thu Oct 23 12:19:57 2025 +0200
Commit:     Noel Grandin <[email protected]>
CommitDate: Fri Oct 24 10:12:35 2025 +0200

    BufferedDecompositionFlusher speed up shutdown
    
    use a condition_variable to speed up termination,
    or we could spend up two seconds waiting to join the background thread
    
    Change-Id: I775a21f01eb55c7529304b5a9da3db157610be83
    Reviewed-on: https://gerrit.libreoffice.org/c/core/+/192904
    Tested-by: Jenkins
    Reviewed-by: Noel Grandin <[email protected]>

diff --git a/drawinglayer/source/primitive2d/BufferedDecompositionFlusher.cxx 
b/drawinglayer/source/primitive2d/BufferedDecompositionFlusher.cxx
index fed3b509178f..c84fbf7fb6d7 100644
--- a/drawinglayer/source/primitive2d/BufferedDecompositionFlusher.cxx
+++ b/drawinglayer/source/primitive2d/BufferedDecompositionFlusher.cxx
@@ -182,17 +182,23 @@ void SAL_CALL BufferedDecompositionFlusher::run()
             aRemoved2.clear();
         }
 
-        wait(TimeValue(2, 0));
+        {
+            std::unique_lock l(maMutex);
+            maDelayOrTerminate.wait_for(l, std::chrono::seconds(2), [this] { 
return mbShutdown; });
+        }
     }
 }
 
 /// Only called by FlusherDeinit
 void BufferedDecompositionFlusher::onTeardown()
 {
-    std::unique_lock l2(maMutex);
-    mbShutdown = true;
-    maRegistered1.clear();
-    maRegistered2.clear();
+    {
+        std::unique_lock l2(maMutex);
+        mbShutdown = true;
+        maRegistered1.clear();
+        maRegistered2.clear();
+    }
+    maDelayOrTerminate.notify_all();
 }
 
 } // end of namespace drawinglayer::primitive2d
diff --git a/include/drawinglayer/primitive2d/BufferedDecompositionFlusher.hxx 
b/include/drawinglayer/primitive2d/BufferedDecompositionFlusher.hxx
index 8b4699d3dce0..8de29113cc82 100644
--- a/include/drawinglayer/primitive2d/BufferedDecompositionFlusher.hxx
+++ b/include/drawinglayer/primitive2d/BufferedDecompositionFlusher.hxx
@@ -23,6 +23,7 @@
 #include <drawinglayer/primitive2d/BufferedDecompositionPrimitive2D.hxx>
 #include <osl/thread.hxx>
 #include <unotools/weakref.hxx>
+#include <condition_variable>
 #include <unordered_map>
 
 namespace drawinglayer::primitive2d
@@ -58,6 +59,7 @@ private:
         maRegistered2;
     std::mutex maMutex;
     bool mbShutdown{ false };
+    std::condition_variable maDelayOrTerminate;
 };
 
 } // end of namespace drawinglayer::primitive2d

Reply via email to