diff options
author | Jan-Marek Glogowski <glogow@fbihome.de> | 2016-10-30 00:03:34 +0200 |
---|---|---|
committer | Jan-Marek Glogowski <glogow@fbihome.de> | 2017-07-13 12:10:21 +0200 |
commit | 1782893282a4543e946e6b2c8de863b10fab0c85 (patch) | |
tree | 4fc64538107668b09e93b152da1a8449fbad7b0b | |
parent | 66a38d26b0c8de82daacfb0c0ce7d014dc083090 (diff) |
Change scheduler list to be queue-like
The scheduler modifies the SchedulerData list mainly in two ways:
1. Remove a finished item
2. Append a new item
This optimizes the Append operation by keeping a last element
pointer, so we don't have to walk the whole list to find it. This
way this list is converted to a queue-like structure.
Change-Id: If7214e1f6016414551abbef11f26f332737f7893
-rw-r--r-- | vcl/inc/svdata.hxx | 13 | ||||
-rw-r--r-- | vcl/source/app/scheduler.cxx | 29 |
2 files changed, 24 insertions, 18 deletions
diff --git a/vcl/inc/svdata.hxx b/vcl/inc/svdata.hxx index e9a80f28a64d..f9de696650ad 100644 --- a/vcl/inc/svdata.hxx +++ b/vcl/inc/svdata.hxx @@ -66,10 +66,6 @@ class Image; class PopupMenu; class Application; class OutputDevice; -namespace vcl -{ - class Window; -} class SystemWindow; class WorkWindow; class Dialog; @@ -101,7 +97,13 @@ class OpenGLContext; #define SV_ICON_ID_DATABASE 12 #define SV_ICON_ID_FORMULA 13 -namespace vcl { class DisplayConnectionDispatch; class SettingsConfigItem; class DeleteOnDeinitBase; } +namespace vcl +{ + class DisplayConnectionDispatch; + class SettingsConfigItem; + class DeleteOnDeinitBase; + class Window; +} class LocaleConfigurationListener : public utl::ConfigurationListener { @@ -320,6 +322,7 @@ struct BlendFrameCache struct ImplSchedulerContext { ImplSchedulerData* mpFirstSchedulerData = nullptr; ///< list of all active tasks + ImplSchedulerData* mpLastSchedulerData = nullptr; ///< last item of the mpFirstSchedulerData list SalTimer* mpSalTimer = nullptr; ///< interface to sal event loop / system timer sal_uInt64 mnTimerPeriod = 0; ///< current timer period sal_uInt64 mnLastProcessTime = 0; ///< last time a task was processed diff --git a/vcl/source/app/scheduler.cxx b/vcl/source/app/scheduler.cxx index dc6ff9fab5a9..9b954f4a1c3f 100644 --- a/vcl/source/app/scheduler.cxx +++ b/vcl/source/app/scheduler.cxx @@ -107,7 +107,8 @@ void Scheduler::ImplDeInitScheduler() } rSchedCtx.mpFirstSchedulerData = nullptr; - rSchedCtx.mnTimerPeriod = 0; + rSchedCtx.mpLastSchedulerData = nullptr; + rSchedCtx.mnTimerPeriod = 0; } /** @@ -234,6 +235,8 @@ bool Scheduler::ProcessTaskScheduling( bool bIdle ) pPrevSchedulerData->mpNext = pSchedulerData->mpNext; else rSchedCtx.mpFirstSchedulerData = pSchedulerData->mpNext; + if ( !pSchedulerData->mpNext ) + rSchedCtx.mpLastSchedulerData = pPrevSchedulerData; if ( pSchedulerData->mpTask ) pSchedulerData->mpTask->mpSchedulerData = nullptr; ImplSchedulerData *pDeleteItem = pSchedulerData; @@ -333,23 +336,23 @@ void Task::Start() if ( !mpSchedulerData ) { // insert Task - mpSchedulerData = new ImplSchedulerData; - mpSchedulerData->mpTask = this; - mpSchedulerData->mbInScheduler = false; + ImplSchedulerData* pSchedulerData = new ImplSchedulerData; + pSchedulerData->mpTask = this; + pSchedulerData->mbInScheduler = false; + pSchedulerData->mpNext = nullptr; + mpSchedulerData = pSchedulerData; // insert last due to SFX! - ImplSchedulerData* pPrev = nullptr; - ImplSchedulerData* pData = rSchedCtx.mpFirstSchedulerData; - while ( pData ) + if ( !rSchedCtx.mpLastSchedulerData ) { - pPrev = pData; - pData = pData->mpNext; + rSchedCtx.mpFirstSchedulerData = pSchedulerData; + rSchedCtx.mpLastSchedulerData = pSchedulerData; } - mpSchedulerData->mpNext = nullptr; - if ( pPrev ) - pPrev->mpNext = mpSchedulerData; else - rSchedCtx.mpFirstSchedulerData = mpSchedulerData; + { + rSchedCtx.mpLastSchedulerData->mpNext = pSchedulerData; + rSchedCtx.mpLastSchedulerData = pSchedulerData; + } SAL_INFO( "vcl.schedule", tools::Time::GetSystemTicks() << " " << mpSchedulerData << " added " << *this ); } |