[Libreoffice-commits] core.git: vcl/source

Jan-Marek Glogowski (via logerrit) logerrit at kemper.freedesktop.org
Sat Apr 27 11:24:06 UTC 2019


 vcl/source/app/svdata.cxx |   24 ++++++------------------
 vcl/source/app/svmain.cxx |    3 ++-
 2 files changed, 8 insertions(+), 19 deletions(-)

New commits:
commit 88048832df5e4b4e81f4f2ec258b2c04063eab14
Author:     Jan-Marek Glogowski <glogow at fbihome.de>
AuthorDate: Fri Apr 26 14:59:34 2019 +0200
Commit:     Michael Meeks <michael.meeks at collabora.com>
CommitDate: Sat Apr 27 13:22:38 2019 +0200

    Use AutoTimer for SystemDependentDataBuffer
    
    This cache eviction timer is periodic, so just use an AutoTimer,
    to prevent the "expensive" Start() calls. This will instantly
    re-schedule the task again. OTOH Stop() is really cheap, as it
    just sets a bool. Same for IsActive(), which just checks that
    bool. We do lazy cleanup of stopped tasks in the scheduler.
    
    This patch also changes the logic to just start the AutoTimer, if
    it's not already running and just stops it in the timer handling
    function, if there is nothing more to do. This way we can save
    allmost all the previous Start() and Stop() calls, but eventually
    have a single unneeded wakeup a second later.
    
    Change-Id: Iae05483f557b94e07e51c4baae25315596923c9c
    Reviewed-on: https://gerrit.libreoffice.org/71376
    Tested-by: Jenkins
    Reviewed-by: Michael Meeks <michael.meeks at collabora.com>

diff --git a/vcl/source/app/svdata.cxx b/vcl/source/app/svdata.cxx
index 0d0930a8646a..5613e8aa7b73 100644
--- a/vcl/source/app/svdata.cxx
+++ b/vcl/source/app/svdata.cxx
@@ -107,15 +107,15 @@ namespace
     class SystemDependentDataBuffer : public basegfx::SystemDependentDataManager, protected cppu::BaseMutex
     {
     private:
-        std::unique_ptr<Timer>  maTimer;
-        EntryMap                maEntries;
+        std::unique_ptr<AutoTimer> maTimer;
+        EntryMap maEntries;
 
         DECL_LINK(implTimeoutHdl, Timer *, void);
 
     public:
         SystemDependentDataBuffer(const sal_Char* pDebugName)
         :   basegfx::SystemDependentDataManager(),
-            maTimer(std::make_unique<Timer>(pDebugName)),
+            maTimer(std::make_unique<AutoTimer>(pDebugName)),
             maEntries()
         {
             maTimer->SetTimeout(1000);
@@ -134,7 +134,7 @@ namespace
 
             if(aFound == maEntries.end())
             {
-                if(maEntries.empty() && maTimer)
+                if(maTimer && !maTimer->IsActive())
                 {
                     maTimer->Start();
                 }
@@ -151,11 +151,6 @@ namespace
             if(aFound != maEntries.end())
             {
                 maEntries.erase(aFound);
-
-                if(maEntries.empty() && maTimer)
-                {
-                    maTimer->Stop();
-                }
             }
         }
 
@@ -207,18 +202,11 @@ namespace
                 EntryMap::iterator aDelete(aIter);
                 ++aIter;
                 maEntries.erase(aDelete);
-
-                if(maEntries.empty() && maTimer)
-                {
-                    maTimer->Stop();
-                }
             }
         }
 
-        if(!maEntries.empty() && maTimer)
-        {
-            maTimer->Start();
-        }
+        if (maEntries.empty())
+            maTimer->Stop();
     }
 }
 
diff --git a/vcl/source/app/svmain.cxx b/vcl/source/app/svmain.cxx
index 6319208896ae..e395e1a8634d 100644
--- a/vcl/source/app/svmain.cxx
+++ b/vcl/source/app/svmain.cxx
@@ -473,7 +473,8 @@ void DeInitVCL()
 
     pSVData->mpSettingsConfigItem.reset();
 
-    // empty and deactivate the SystemDependentDataManager
+    // prevent unnessesary painting during Scheduler shutdown
+    // as this processes all pending events in debug builds.
     ImplGetSystemDependentDataManager().flushAll();
 
     Scheduler::ImplDeInitScheduler();


More information about the Libreoffice-commits mailing list