diff options
author | Jan-Marek Glogowski <glogow@fbihome.de> | 2021-06-27 12:55:42 +0200 |
---|---|---|
committer | Jan-Marek Glogowski <glogow@fbihome.de> | 2021-06-27 18:06:33 +0200 |
commit | 642791720622618c9b66633c3e1224a4d340b167 (patch) | |
tree | 195c53b9f0c132ac1fc07f3db86df631af196408 /include | |
parent | de873f01d286d57829d8fb78d1f2748372552d37 (diff) |
Immediately schedule Tasks on start per default
While writing a new Task, I was wondering, why it didn't schedule
immediatly after calling Start(). Turned out Start() wasn't even
calling Task::StartTimer(...) to trigger / wake up the Scheduler.
So this changes Task's Start() to call StartTimer(0) to immediatly
trigger the Scheduler at the end of Start(), but Tasks can opt out
of it, if they aren't ready yet (like Timers).
Change-Id: Ia2fdb45f502866c83f432b045e70bf27ccb61012
Reviewed-on: https://gerrit.libreoffice.org/c/core/+/117947
Tested-by: Jenkins
Reviewed-by: Jan-Marek Glogowski <glogow@fbihome.de>
Diffstat (limited to 'include')
-rw-r--r-- | include/vcl/idle.hxx | 2 | ||||
-rw-r--r-- | include/vcl/task.hxx | 13 | ||||
-rw-r--r-- | include/vcl/timer.hxx | 8 |
3 files changed, 14 insertions, 9 deletions
diff --git a/include/vcl/idle.hxx b/include/vcl/idle.hxx index 78fcaae817b9..9abafae440d8 100644 --- a/include/vcl/idle.hxx +++ b/include/vcl/idle.hxx @@ -46,7 +46,7 @@ protected: public: Idle( const char *pDebugName = nullptr ); - virtual void Start() override; + virtual void Start(bool bStartTimer = true) override; }; /** diff --git a/include/vcl/task.hxx b/include/vcl/task.hxx index e95aa5bc460a..3785e37fba53 100644 --- a/include/vcl/task.hxx +++ b/include/vcl/task.hxx @@ -85,7 +85,18 @@ public: // Call handler virtual void Invoke() = 0; - virtual void Start(); + /** + * Schedules the task for execution + * + * If the timer is already active, it's reset! + * Check with Task::IsActive() to prevent reset. + * + * If you unset bStartTimer, the Task must call Task::StartTimer(...) to be correctly scheduled! + * Otherwise it might just be picked up when the Scheduler runs the next time. + * + * @param bStartTimer if false, don't schedule the Task by calling Task::StartTimer(0). + */ + virtual void Start(bool bStartTimer = true); void Stop(); bool IsActive() const { return mbActive; } diff --git a/include/vcl/timer.hxx b/include/vcl/timer.hxx index d9ad82ee5729..cd8733518093 100644 --- a/include/vcl/timer.hxx +++ b/include/vcl/timer.hxx @@ -58,13 +58,7 @@ public: void SetTimeout( sal_uInt64 nTimeoutMs ); sal_uInt64 GetTimeout() const { return mnTimeout; } - /** - * Activates the timer task - * - * If the timer is already active, it's reset! - * Check with Task::IsActive() to prevent reset. - */ - virtual void Start() override; + virtual void Start(bool bStartTimer = true) override; }; /// An auto-timer is a multi-shot timer re-emitting itself at |