Kaydet (Commit) 88048832 authored tarafından Jan-Marek Glogowski's avatar Jan-Marek Glogowski Kaydeden (comit) Michael Meeks

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: 's avatarMichael Meeks <michael.meeks@collabora.com>
üst 3bf32679
...@@ -107,15 +107,15 @@ namespace ...@@ -107,15 +107,15 @@ namespace
class SystemDependentDataBuffer : public basegfx::SystemDependentDataManager, protected cppu::BaseMutex class SystemDependentDataBuffer : public basegfx::SystemDependentDataManager, protected cppu::BaseMutex
{ {
private: private:
std::unique_ptr<Timer> maTimer; std::unique_ptr<AutoTimer> maTimer;
EntryMap maEntries; EntryMap maEntries;
DECL_LINK(implTimeoutHdl, Timer *, void); DECL_LINK(implTimeoutHdl, Timer *, void);
public: public:
SystemDependentDataBuffer(const sal_Char* pDebugName) SystemDependentDataBuffer(const sal_Char* pDebugName)
: basegfx::SystemDependentDataManager(), : basegfx::SystemDependentDataManager(),
maTimer(std::make_unique<Timer>(pDebugName)), maTimer(std::make_unique<AutoTimer>(pDebugName)),
maEntries() maEntries()
{ {
maTimer->SetTimeout(1000); maTimer->SetTimeout(1000);
...@@ -134,7 +134,7 @@ namespace ...@@ -134,7 +134,7 @@ namespace
if(aFound == maEntries.end()) if(aFound == maEntries.end())
{ {
if(maEntries.empty() && maTimer) if(maTimer && !maTimer->IsActive())
{ {
maTimer->Start(); maTimer->Start();
} }
...@@ -151,11 +151,6 @@ namespace ...@@ -151,11 +151,6 @@ namespace
if(aFound != maEntries.end()) if(aFound != maEntries.end())
{ {
maEntries.erase(aFound); maEntries.erase(aFound);
if(maEntries.empty() && maTimer)
{
maTimer->Stop();
}
} }
} }
...@@ -207,18 +202,11 @@ namespace ...@@ -207,18 +202,11 @@ namespace
EntryMap::iterator aDelete(aIter); EntryMap::iterator aDelete(aIter);
++aIter; ++aIter;
maEntries.erase(aDelete); maEntries.erase(aDelete);
if(maEntries.empty() && maTimer)
{
maTimer->Stop();
}
} }
} }
if(!maEntries.empty() && maTimer) if (maEntries.empty())
{ maTimer->Stop();
maTimer->Start();
}
} }
} }
......
...@@ -473,7 +473,8 @@ void DeInitVCL() ...@@ -473,7 +473,8 @@ void DeInitVCL()
pSVData->mpSettingsConfigItem.reset(); 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(); ImplGetSystemDependentDataManager().flushAll();
Scheduler::ImplDeInitScheduler(); Scheduler::ImplDeInitScheduler();
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment