diff options
author | Jan-Marek Glogowski <glogow@fbihome.de> | 2017-01-04 12:06:42 +0100 |
---|---|---|
committer | Jan-Marek Glogowski <glogow@fbihome.de> | 2017-01-17 16:08:47 +0100 |
commit | fdc612619c1c133353026166206cea18c48089a6 (patch) | |
tree | 900ab53bc8d88ed4ab4b375e8a80136401bc3145 /include | |
parent | 17bb38262471cf68167fa11ad875c2785f43a341 (diff) |
Refactor Scheduler to add Task class
Moves all the "task-specific" stuff into a Task class and just
keeps the "real" static Scheduler functions in the original
Scheduler class.
Change-Id: I9eb02d46e2bcf1abb06af5bab1fa0ee734d1984c
Diffstat (limited to 'include')
-rw-r--r-- | include/vcl/idle.hxx | 2 | ||||
-rw-r--r-- | include/vcl/scheduler.hxx | 84 | ||||
-rw-r--r-- | include/vcl/timer.hxx | 2 |
3 files changed, 52 insertions, 36 deletions
diff --git a/include/vcl/idle.hxx b/include/vcl/idle.hxx index d3fdfbb5f78e..9f491e1ad9f7 100644 --- a/include/vcl/idle.hxx +++ b/include/vcl/idle.hxx @@ -23,7 +23,7 @@ #include <tools/link.hxx> #include <vcl/scheduler.hxx> -class VCL_DLLPUBLIC Idle : public Scheduler +class VCL_DLLPUBLIC Idle : public Task { Link<Idle *, void> maIdleHdl; // Callback Link diff --git a/include/vcl/scheduler.hxx b/include/vcl/scheduler.hxx index 16aba06a4b59..1e4b9d628a0d 100644 --- a/include/vcl/scheduler.hxx +++ b/include/vcl/scheduler.hxx @@ -22,9 +22,43 @@ #include <vcl/dllapi.h> +class Task; + +class VCL_DLLPUBLIC Scheduler +{ + friend class Task; + Scheduler() = delete; + +protected: + static void ImplStartTimer ( sal_uInt64 nMS, bool bForce = false ); + +public: + static const SAL_CONSTEXPR sal_uInt64 ImmediateTimeoutMs = 1; + static const SAL_CONSTEXPR sal_uInt64 InfiniteTimeoutMs = 1000 * 60 * 60 * 24; // 1 day + + static void ImplDeInitScheduler(); + + /// Process one pending Timer with highhest priority + static void CallbackTaskScheduling( bool ignore ); + /// Calculate minimum timeout - and return its value. + static sal_uInt64 CalculateMinimumTimeout( bool &bHasActiveIdles ); + /// Process one pending task ahead of time with highest priority. + static bool ProcessTaskScheduling( bool bIdle ); + /// Process all events until we are idle + static void ProcessEventsToIdle(); + + /// Control the deterministic mode. In this mode, two subsequent runs of + /// LibreOffice fire about the same amount idles. + static void SetDeterministicMode(bool bDeterministic); + /// Return the current state of deterministic mode. + static bool GetDeterministicMode(); +}; + + struct ImplSchedulerData; -enum class SchedulerPriority { +enum class TaskPriority +{ HIGHEST = 0, HIGH = 1, RESIZE = 2, @@ -37,21 +71,19 @@ enum class SchedulerPriority { LOWEST = 8 }; -class VCL_DLLPUBLIC Scheduler +class VCL_DLLPUBLIC Task { -protected: - ImplSchedulerData* mpSchedulerData; /// Pointer to element in scheduler list - const sal_Char *mpDebugName; /// Useful for debugging - SchedulerPriority mePriority; /// Scheduler priority - bool mbActive; /// Currently in the scheduler + friend class Scheduler; + friend struct ImplSchedulerData; - // These should be constexpr static, when supported. - static const sal_uInt64 ImmediateTimeoutMs = 1; - static const sal_uInt64 InfiniteTimeoutMs = 1000 * 60 * 60 * 24; // 1 day +protected: + ImplSchedulerData *mpSchedulerData; /// Pointer to the element in scheduler list + const sal_Char *mpDebugName; /// Useful for debugging + TaskPriority mePriority; /// Task priority + bool mbActive; /// Currently in the scheduler - static void ImplStartTimer(sal_uInt64 nMS, bool bForce = false); + void StartTimer( sal_uInt64 nMS ); - friend struct ImplSchedulerData; virtual void SetDeletionFlags(); /// Is this item ready to be dispatched at nTimeNow virtual bool ReadyForSchedule( bool bIdle, sal_uInt64 nTimeNow ) const = 0; @@ -64,12 +96,12 @@ protected: virtual sal_uInt64 UpdateMinPeriod( sal_uInt64 nMinPeriod, sal_uInt64 nTimeNow ) const = 0; public: - Scheduler( const sal_Char *pDebugName ); - Scheduler( const Scheduler& rScheduler ); - virtual ~Scheduler(); + Task( const sal_Char *pDebugName ); + Task( const Task& rTask ); + virtual ~Task(); - void SetPriority(SchedulerPriority ePriority) { mePriority = ePriority; } - SchedulerPriority GetPriority() const { return mePriority; } + void SetPriority(TaskPriority ePriority) { mePriority = ePriority; } + TaskPriority GetPriority() const { return mePriority; } void SetDebugName( const sal_Char *pDebugName ) { mpDebugName = pDebugName; } const char *GetDebugName() { return mpDebugName; } @@ -82,23 +114,7 @@ public: bool IsActive() const { return mbActive; } - Scheduler& operator=( const Scheduler& rScheduler ); - static void ImplDeInitScheduler(); - - /// Process one pending Timer with highhest priority - static void CallbackTaskScheduling( bool ignore ); - /// Calculate minimum timeout - and return its value. - static sal_uInt64 CalculateMinimumTimeout( bool &bHasActiveIdles ); - /// Process one pending task ahead of time with highest priority. - static bool ProcessTaskScheduling( bool bIdle ); - /// Process all events until we are idle - static void ProcessEventsToIdle(); - - /// Control the deterministic mode. In this mode, two subsequent runs of - /// LibreOffice fire about the same amount idles. - static void SetDeterministicMode(bool bDeterministic); - /// Return the current state of deterministic mode. - static bool GetDeterministicMode(); + Task& operator=( const Task& rTask ); }; #endif // INCLUDED_VCL_SCHEDULER_HXX diff --git a/include/vcl/timer.hxx b/include/vcl/timer.hxx index ff79acde2936..19a882f02555 100644 --- a/include/vcl/timer.hxx +++ b/include/vcl/timer.hxx @@ -23,7 +23,7 @@ #include <tools/link.hxx> #include <vcl/scheduler.hxx> -class VCL_DLLPUBLIC Timer : public Scheduler +class VCL_DLLPUBLIC Timer : public Task { protected: Link<Timer *, void> maTimeoutHdl; // Callback Link |