diff options
author | Jan-Marek Glogowski <glogow@fbihome.de> | 2019-04-26 14:59:34 +0200 |
---|---|---|
committer | Michael Meeks <michael.meeks@collabora.com> | 2019-04-27 13:22:38 +0200 |
commit | 88048832df5e4b4e81f4f2ec258b2c04063eab14 (patch) | |
tree | 56f1cbbeab2f792edb8052d1606630c1187e7268 /vcl/source/app/svdata.cxx | |
parent | 3bf32679971804ade8e85f0e8023dc3b127cc3dc (diff) |
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@collabora.com>
Diffstat (limited to 'vcl/source/app/svdata.cxx')
-rw-r--r-- | vcl/source/app/svdata.cxx | 24 |
1 files changed, 6 insertions, 18 deletions
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(); } } |