[Libreoffice-commits] core.git: 3 commits - vcl/source vcl/win
Jan-Marek Glogowski
glogow at fbihome.de
Mon Jul 24 16:16:41 UTC 2017
vcl/source/app/scheduler.cxx | 15 +++++++++++----
vcl/win/app/salinst.cxx | 7 ++++---
vcl/win/app/saltimer.cxx | 2 +-
vcl/win/gdi/salprn.cxx | 36 +++---------------------------------
vcl/win/window/salframe.cxx | 9 +--------
5 files changed, 20 insertions(+), 49 deletions(-)
New commits:
commit 4815b6f7c70cca5a226163caaaab8a227f32be48
Author: Jan-Marek Glogowski <glogow at fbihome.de>
Date: Mon Jul 24 15:45:32 2017 +0200
WIN don't yield the scheduler in PeekMessage
The scheduler is restarting the timer at the end of the most
important task search. It uses PeekMessage PM_REMOVE to remove
old SAL_MSG_TIMER_CALLBACK messages from the queue.
Without PM_NOYIELD, in combination with an other thread yielding
using SAL_MSG_THREADYIELD, this could re-start scheduling inside
these PeekMessage calls, resulting in various assertions inside
the scheduler code, most time due to the changed ascheduler list
in "assert( pPrevSchedulerData->mpNext == pSchedulerData )".
Change-Id: Ia96b6c0e06ffc3126b1428723b53f4b2112f8a5f
diff --git a/vcl/win/app/salinst.cxx b/vcl/win/app/salinst.cxx
index 8e718e37e883..cfffb97d0234 100644
--- a/vcl/win/app/salinst.cxx
+++ b/vcl/win/app/salinst.cxx
@@ -730,7 +730,7 @@ LRESULT CALLBACK SalComWndProc( HWND, UINT nMsg, WPARAM wParam, LPARAM lParam, i
case SAL_MSG_TIMER_CALLBACK:
MSG aMsg;
while ( PeekMessageW(&aMsg, nullptr, SAL_MSG_TIMER_CALLBACK,
- SAL_MSG_TIMER_CALLBACK, PM_REMOVE) )
+ SAL_MSG_TIMER_CALLBACK, PM_REMOVE | PM_NOYIELD) )
assert( "Multiple timer messages in queue" );
assert( 0 == wParam );
if ( 0 == wParam )
diff --git a/vcl/win/app/saltimer.cxx b/vcl/win/app/saltimer.cxx
index ae8ed0790bf5..4ca5ebb572d2 100644
--- a/vcl/win/app/saltimer.cxx
+++ b/vcl/win/app/saltimer.cxx
@@ -49,7 +49,7 @@ void ImplSalStopTimer()
MSG aMsg;
int nMsgCount = 0;
while ( PeekMessageW(&aMsg, nullptr, SAL_MSG_TIMER_CALLBACK,
- SAL_MSG_TIMER_CALLBACK, PM_REMOVE) )
+ SAL_MSG_TIMER_CALLBACK, PM_REMOVE | PM_NOYIELD) )
nMsgCount++;
assert( nMsgCount <= 1 );
pSalData->mbOnIdleRunScheduler = false;
commit 9dfd1bb102bb08f0651a6921722d731ab973bd08
Author: Jan-Marek Glogowski <glogow at fbihome.de>
Date: Mon Jul 24 15:41:32 2017 +0200
Add some const and fix some scheduler logging
Change-Id: Id20767ff2be34a21896d3ce2b76f3944acdb1b77
diff --git a/vcl/source/app/scheduler.cxx b/vcl/source/app/scheduler.cxx
index e9372cd52c3e..972beb741c1d 100644
--- a/vcl/source/app/scheduler.cxx
+++ b/vcl/source/app/scheduler.cxx
@@ -178,9 +178,9 @@ inline void Scheduler::UpdateSystemTimer( ImplSchedulerContext &rSchedCtx,
{
if ( InfiniteTimeoutMs == nMinPeriod )
{
+ SAL_INFO("vcl.schedule", " Stopping system timer");
if ( rSchedCtx.mpSalTimer )
rSchedCtx.mpSalTimer->Stop();
- SAL_INFO("vcl.schedule", " Stopping system timer");
rSchedCtx.mnTimerPeriod = nMinPeriod;
}
else
@@ -205,9 +205,13 @@ static inline void AppendSchedulerData( ImplSchedulerContext &rSchedCtx,
static inline ImplSchedulerData* DropSchedulerData(
ImplSchedulerContext &rSchedCtx, ImplSchedulerData * const pPrevSchedulerData,
- ImplSchedulerData * const pSchedulerData )
+ const ImplSchedulerData * const pSchedulerData )
{
- assert( !pPrevSchedulerData || (pPrevSchedulerData->mpNext == pSchedulerData) );
+ assert( pSchedulerData );
+ if ( pPrevSchedulerData )
+ assert( pPrevSchedulerData->mpNext == pSchedulerData );
+ else
+ assert( rSchedCtx.mpFirstSchedulerData == pSchedulerData );
ImplSchedulerData * const pSchedulerDataNext = pSchedulerData->mpNext;
if ( pPrevSchedulerData )
@@ -312,7 +316,7 @@ next_entry:
if ( pMostUrgent )
{
SAL_INFO( "vcl.schedule", tools::Time::GetSystemTicks() << " "
- << pMostUrgent << " invoke " << *pMostUrgent->mpTask );
+ << pMostUrgent << " invoke-in " << *pMostUrgent->mpTask );
Task *pTask = pMostUrgent->mpTask;
@@ -328,6 +332,9 @@ next_entry:
pTask->Invoke();
pMostUrgent->mbInScheduler = false;
+ SAL_INFO( "vcl.schedule", tools::Time::GetSystemTicks() << " "
+ << pMostUrgent << " invoke-out" );
+
// eventually pop the scheduler stack
// this just happens for nested calls, which renders all accounting
// invalid, so we just enforce a rescheduling!
diff --git a/vcl/win/app/salinst.cxx b/vcl/win/app/salinst.cxx
index 6833c546a5ce..8e718e37e883 100644
--- a/vcl/win/app/salinst.cxx
+++ b/vcl/win/app/salinst.cxx
@@ -245,8 +245,8 @@ sal_uLong ImplSalReleaseYieldMutex()
return 0;
SalYieldMutex* pYieldMutex = pInst->mpSalYieldMutex;
- sal_uLong nCount = pYieldMutex->GetAcquireCount( GetCurrentThreadId() );
- sal_uLong n = nCount;
+ const sal_uLong nCount = pYieldMutex->GetAcquireCount( GetCurrentThreadId() );
+ sal_uLong n = nCount;
while ( n )
{
pYieldMutex->release();
commit 221b0ab1245be6dba23b4ef3c516e846d95d2f71
Author: Jan-Marek Glogowski <glogow at fbihome.de>
Date: Thu Jul 20 15:49:45 2017 +0200
WIN use Reschedule instead of own dispatch loops
Since we're filtering the wakeup timer event in the main dispatch
loop, we should use Application::Reschedule in the Backend.
Change-Id: Ie02c3533e8a6a7905281f129489e4f6f53f74692
diff --git a/vcl/win/app/salinst.cxx b/vcl/win/app/salinst.cxx
index 7e76cd921273..6833c546a5ce 100644
--- a/vcl/win/app/salinst.cxx
+++ b/vcl/win/app/salinst.cxx
@@ -732,6 +732,7 @@ LRESULT CALLBACK SalComWndProc( HWND, UINT nMsg, WPARAM wParam, LPARAM lParam, i
while ( PeekMessageW(&aMsg, nullptr, SAL_MSG_TIMER_CALLBACK,
SAL_MSG_TIMER_CALLBACK, PM_REMOVE) )
assert( "Multiple timer messages in queue" );
+ assert( 0 == wParam );
if ( 0 == wParam )
EmitTimerCallback();
break;
diff --git a/vcl/win/gdi/salprn.cxx b/vcl/win/gdi/salprn.cxx
index 44cc665c94b4..153ec5c54928 100644
--- a/vcl/win/gdi/salprn.cxx
+++ b/vcl/win/gdi/salprn.cxx
@@ -1288,24 +1288,12 @@ BOOL CALLBACK SalPrintAbortProc( HDC hPrnDC, int /* nError */ )
{
SalData* pSalData = GetSalData();
WinSalPrinter* pPrinter;
- bool bWhile = TRUE;
- int i = 0;
+ bool bWhile = true;
do
{
// process messages
- MSG aMsg;
- if ( PeekMessageW( &aMsg, nullptr, 0, 0, PM_REMOVE ) )
- {
- TranslateMessage( &aMsg );
- DispatchMessageW( &aMsg );
-
- i++;
- if ( i > 15 )
- bWhile = FALSE;
- }
- else
- bWhile = FALSE;
+ bWhile = Application::Reschedule( true );
pPrinter = pSalData->mpFirstPrinter;
while ( pPrinter )
@@ -1468,25 +1456,7 @@ bool WinSalPrinter::StartJob( const OUString* pFileName,
// As the Telecom Balloon Fax driver tends to send messages repeatedly
// we try to process first all, and then insert a dummy message
- bool bWhile = TRUE;
- int i = 0;
- do
- {
- // process messages
- MSG aMsg;
- if ( PeekMessageW( &aMsg, nullptr, 0, 0, PM_REMOVE ) )
- {
- TranslateMessage( &aMsg );
- DispatchMessageW( &aMsg );
-
- i++;
- if ( i > 15 )
- bWhile = FALSE;
- }
- else
- bWhile = FALSE;
- }
- while ( bWhile );
+ while ( Application::Reschedule( true ) );
BOOL const ret = PostMessageW(GetSalData()->mpFirstInstance->mhComWnd, SAL_MSG_DUMMY, 0, 0);
SAL_WARN_IF(0 == ret, "vcl", "ERROR: PostMessage() failed!");
diff --git a/vcl/win/window/salframe.cxx b/vcl/win/window/salframe.cxx
index 268da1e2666f..e0ec83c37e4c 100644
--- a/vcl/win/window/salframe.cxx
+++ b/vcl/win/window/salframe.cxx
@@ -5705,14 +5705,7 @@ LRESULT CALLBACK SalFrameWndProc( HWND hWnd, UINT nMsg, WPARAM wParam, LPARAM lP
// messages in the message queue and dispatch them before we return control to the system.
if ( nRet )
- {
- MSG msg;
-
- while( PeekMessage( &msg, nullptr, 0, 0, PM_REMOVE ) )
- {
- DispatchMessage( &msg );
- }
- }
+ while ( Application::Reschedule( true ) );
}
else
{
More information about the Libreoffice-commits
mailing list