summaryrefslogtreecommitdiff
path: root/vcl/source
diff options
context:
space:
mode:
authorJan-Marek Glogowski <glogow@fbihome.de>2017-01-20 13:24:02 +0100
committerJan-Marek Glogowski <glogow@fbihome.de>2017-07-13 12:10:21 +0200
commit66a38d26b0c8de82daacfb0c0ce7d014dc083090 (patch)
tree899e70e60c3587f46e280aa80722df5486d885d2 /vcl/source
parenteb2035fe20bdebf0f8c926aeb66553fd9db3e6f4 (diff)
Just walk the task list once
This refactors some more scheduler code by merging the code from ProcessTaskScheduling into CalculateMinimumTimeout and keeping the ProcessTaskScheduling name. It replace the bHasPendingIdles information with a HasPendingTasks function, based on the sleep timeout and invoke time. To drop IsIdle() we simply account Idles again and stop the system timer, so we instantly run our application loop again. This makes all Tasks really run immediate instead of waiting 1ms. Change-Id: I690a8754e6b115a53e74ef777e988b66b4e5037f
Diffstat (limited to 'vcl/source')
-rw-r--r--vcl/source/app/idle.cxx9
-rw-r--r--vcl/source/app/svapp.cxx16
-rw-r--r--vcl/source/app/timer.cxx5
3 files changed, 7 insertions, 23 deletions
diff --git a/vcl/source/app/idle.cxx b/vcl/source/app/idle.cxx
index 8f5f8c002b08..912c79a65d57 100644
--- a/vcl/source/app/idle.cxx
+++ b/vcl/source/app/idle.cxx
@@ -19,6 +19,7 @@
#include <vcl/idle.hxx>
#include <vcl/scheduler.hxx>
+#include <svdata.hxx>
#include "saltimer.hxx"
Idle::Idle( bool bAuto, const sal_Char *pDebugName )
@@ -57,17 +58,13 @@ void Idle::Start()
bool Idle::ReadyForSchedule( bool bIdle, sal_uInt64 /* nTimeNow */ ) const
{
// always ready if not only looking for timers.
+ ImplSVData *pSVData = ImplGetSVData();
+ pSVData->maSchedCtx.mbNeedsReschedule = true;
return bIdle;
}
-bool Idle::IsIdle() const
-{
- return true;
-}
-
sal_uInt64 Idle::UpdateMinPeriod( sal_uInt64 /* nMinPeriod */, sal_uInt64 /* nTimeNow */ ) const
{
- assert(false); // idles currently don't hit this.
return Scheduler::ImmediateTimeoutMs;
}
diff --git a/vcl/source/app/svapp.cxx b/vcl/source/app/svapp.cxx
index ea6e0807cc7e..3a5c89850431 100644
--- a/vcl/source/app/svapp.cxx
+++ b/vcl/source/app/svapp.cxx
@@ -469,17 +469,9 @@ inline bool ImplYield(bool i_bWait, bool i_bAllEvents, sal_uLong const nReleased
SAL_INFO("vcl.schedule", "Enter ImplYield: " << (i_bWait ? "wait" : "no wait") <<
": " << (i_bAllEvents ? "all events" : "one event") << ": " << nReleased);
- bool bHasActiveIdles = false;
- sal_uInt64 nMinTimeout = 0;
- if (nReleased == 0) // else thread doesn't have SolarMutex so avoid race
- nMinTimeout = Scheduler::CalculateMinimumTimeout(bHasActiveIdles);
-
- // FIXME: should use returned value as param to DoYield
- (void)nMinTimeout;
-
// If we have idles, don't wait for the timeout; check for events
// and come back as quick as possible.
- if (bHasActiveIdles)
+ if (i_bWait && Scheduler::HasPendingTasks())
i_bWait = false;
// TODO: there's a data race here on WNT only because ImplYield may be
@@ -497,8 +489,8 @@ inline bool ImplYield(bool i_bWait, bool i_bAllEvents, sal_uLong const nReleased
i_bWait && !pSVData->maAppData.mbAppQuit,
i_bAllEvents, nReleased);
- SAL_INFO("vcl.schedule", "DoYield with " << (bHasActiveIdles ? "active idles" : "no idles") <<
- " returns: " << (eResult == SalYieldResult::EVENT ? "processed event" : "timeout"));
+ SAL_INFO("vcl.schedule", "DoYield returns: "
+ << (eResult == SalYieldResult::EVENT ? "processed event" : "timeout"));
pSVData->maAppData.mnDispatchLevel--;
@@ -516,7 +508,7 @@ inline bool ImplYield(bool i_bWait, bool i_bAllEvents, sal_uLong const nReleased
SAL_INFO("vcl.schedule", "Leave ImplYield");
- return bHasActiveIdles || eResult == SalYieldResult::EVENT;
+ return Scheduler::HasPendingTasks() || eResult == SalYieldResult::EVENT;
}
bool Application::Reschedule( bool i_bAllEvents )
diff --git a/vcl/source/app/timer.cxx b/vcl/source/app/timer.cxx
index 924ef62d0881..e1b6ac777ca5 100644
--- a/vcl/source/app/timer.cxx
+++ b/vcl/source/app/timer.cxx
@@ -35,11 +35,6 @@ bool Timer::ReadyForSchedule( bool /* bIdle */, sal_uInt64 nTimeNow ) const
return (GetSchedulerData()->mnUpdateTime + mnTimeout) <= nTimeNow;
}
-bool Timer::IsIdle() const
-{
- return false;
-}
-
sal_uInt64 Timer::UpdateMinPeriod( sal_uInt64 nMinPeriod, sal_uInt64 nTimeNow ) const
{
sal_uInt64 nWakeupTime = GetSchedulerData()->mnUpdateTime + mnTimeout;