diff options
author | Jan Holesovsky <kendy@collabora.com> | 2016-05-30 17:36:37 +0200 |
---|---|---|
committer | Jan Holesovsky <kendy@collabora.com> | 2016-05-31 15:23:59 +0200 |
commit | 3f98cf32836eb10af7fc673b1fe61421fcb98d3b (patch) | |
tree | 24fcdc76db48d721fe95a37cce5c401723466cc5 /vcl | |
parent | da27c5d58948a782f25338320f9c57cfe542986e (diff) |
tdf#100092: Deterministic scheduling to prevent unpredictable behavior.
Low priority idles can fire more or less randomly, and consequently two
consequent runs of LibreOffice differ in the amount of the idles that have
been performed during an operation.
This commit adds a possibility to turn on a 'deterministic mode' where two
subsequent runs of LibreOffice trigger about the same amount of events when
they perform the same set of operations.
Change-Id: I92566ef4eee20e7d604cfd48f01c4df30c77e653
Diffstat (limited to 'vcl')
-rw-r--r-- | vcl/source/app/idle.cxx | 18 | ||||
-rw-r--r-- | vcl/source/app/scheduler.cxx | 12 |
2 files changed, 29 insertions, 1 deletions
diff --git a/vcl/source/app/idle.cxx b/vcl/source/app/idle.cxx index ad9829b97074..10a7a495a92f 100644 --- a/vcl/source/app/idle.cxx +++ b/vcl/source/app/idle.cxx @@ -44,7 +44,23 @@ Idle::Idle( const Idle& rIdle ) : Scheduler(rIdle) void Idle::Start() { Scheduler::Start(); - Scheduler::ImplStartTimer(Scheduler::ImmediateTimeoutMs); + + sal_uInt64 nPeriod = Scheduler::ImmediateTimeoutMs; + if (Scheduler::GetDeterministicMode()) + { + switch (mePriority) + { + case SchedulerPriority::LOW: + case SchedulerPriority::LOWER: + case SchedulerPriority::LOWEST: + nPeriod = Scheduler::InfiniteTimeoutMs; + break; + default: + break; + } + } + + Scheduler::ImplStartTimer(nPeriod); } bool Idle::ReadyForSchedule( bool bTimerOnly, sal_uInt64 /* nTimeNow */ ) const diff --git a/vcl/source/app/scheduler.cxx b/vcl/source/app/scheduler.cxx index 291c4f73571c..4dcbc4d196b6 100644 --- a/vcl/source/app/scheduler.cxx +++ b/vcl/source/app/scheduler.cxx @@ -181,6 +181,18 @@ bool Scheduler::ProcessTaskScheduling( bool bTimerOnly ) return false; } +static bool g_bDeterministicMode = false; + +void Scheduler::SetDeterministicMode(bool bDeterministic) +{ + g_bDeterministicMode = bDeterministic; +} + +bool Scheduler::GetDeterministicMode() +{ + return g_bDeterministicMode; +} + sal_uInt64 Scheduler::CalculateMinimumTimeout( bool &bHasActiveIdles ) { // process all pending Tasks |