diff options
author | Jan-Marek Glogowski <glogow@fbihome.de> | 2017-10-16 16:59:45 +0200 |
---|---|---|
committer | Jan-Marek Glogowski <glogow@fbihome.de> | 2017-10-20 10:45:58 +0200 |
commit | 47ee8098a90a35626dcace7422a9a624c8469389 (patch) | |
tree | 15bd87d280036aec701328ee8c770e3c4c9de138 | |
parent | 9466ea1af09c275f423b0d5c1ad929984ed998b3 (diff) |
WIN guarantee direct timeout handling
The code did acccount processing of an invaild timeout system
message as a valid timeout event.
Change-Id: I3c31f8b9cec592631b4089411163dadecffde816
Reviewed-on: https://gerrit.libreoffice.org/43529
Tested-by: Jenkins <ci@libreoffice.org>
Reviewed-by: Jan-Marek Glogowski <glogow@fbihome.de>
-rw-r--r-- | vcl/README.scheduler | 29 | ||||
-rw-r--r-- | vcl/inc/win/saltimer.h | 4 | ||||
-rw-r--r-- | vcl/win/app/salinst.cxx | 25 | ||||
-rw-r--r-- | vcl/win/app/saltimer.cxx | 14 |
4 files changed, 54 insertions, 18 deletions
diff --git a/vcl/README.scheduler b/vcl/README.scheduler index 17648ae3b439..80c14b032c54 100644 --- a/vcl/README.scheduler +++ b/vcl/README.scheduler @@ -89,6 +89,35 @@ can be added to the scheduler reasonably. = Implementation details = +== General: event priority for DoYield == + +There are three types of events, with different priority: + +1. LO user events +2. System events +3. LO Scheduler event + +They should be processed according to the following code: + +bool DoYield( bool bWait, bool bAllCurrent ) +{ + bool bWasEvent = ProcessUserEvents( bAllCurrent ); + if ( !bAllCurrent && bWasEvent ) + return true; + bWasEvent = ProcessSystemEvents( bAllCurrent, &bWasSchedulerEvent ) || bWasEvent; + if ( !bWasSchedulerEvent && IsSchedulerEvent() ) + { + ProcessSchedulerEvent() + bWasEvent = true; + } + if ( !bWasEvent && bWait ) + { + WaitForSystemEvents(); + bWasEvent = true; + } + return bWasEvent; +} + == General: main thread deferral == Currently for Mac and Windows, we run main thread deferrals by disabling the diff --git a/vcl/inc/win/saltimer.h b/vcl/inc/win/saltimer.h index d762b51b6716..b7d1a1e0d0f1 100644 --- a/vcl/inc/win/saltimer.h +++ b/vcl/inc/win/saltimer.h @@ -42,9 +42,9 @@ class WinSalTimer final : public SalTimer, protected VersionedEvent void ImplStart( sal_uIntPtr nMS ); void ImplStop(); - void ImplHandleTimerEvent( WPARAM aWPARAM ); + bool ImplHandleTimerEvent( WPARAM aWPARAM ); void ImplHandleElapsedTimer(); - void ImplHandle_WM_TIMER( WPARAM aWPARAM ); + bool ImplHandle_WM_TIMER( WPARAM aWPARAM ); public: WinSalTimer(); diff --git a/vcl/win/app/salinst.cxx b/vcl/win/app/salinst.cxx index d1fc8adb6272..693411a0583c 100644 --- a/vcl/win/app/salinst.cxx +++ b/vcl/win/app/salinst.cxx @@ -459,17 +459,15 @@ void WinSalInstance::AcquireYieldMutex( sal_uInt32 nCount ) mpSalYieldMutex->acquire( nCount ); } -static void ImplSalDispatchMessage( MSG* pMsg ) +static LRESULT ImplSalDispatchMessage( MSG* pMsg ) { SalData* pSalData = GetSalData(); - if ( pSalData->mpFirstObject ) - { - if ( ImplSalPreDispatchMsg( pMsg ) ) - return; - } + if ( pSalData->mpFirstObject && ImplSalPreDispatchMsg( pMsg ) ) + return 0; LRESULT lResult = DispatchMessageW( pMsg ); if ( pSalData->mpFirstObject ) ImplSalPostDispatchMsg( pMsg, lResult ); + return lResult; } bool ImplSalYield( bool bWait, bool bHandleAllCurrentEvents ) @@ -491,10 +489,13 @@ bool ImplSalYield( bool bWait, bool bHandleAllCurrentEvents ) if ( bOneEvent ) { bWasMsg = true; - if ( !bWasTimeoutMsg ) - bWasTimeoutMsg = (SAL_MSG_TIMER_CALLBACK == aMsg.message); TranslateMessage( &aMsg ); - ImplSalDispatchMessage( &aMsg ); + LRESULT nRet = ImplSalDispatchMessage( &aMsg ); + + if ( !bWasTimeoutMsg ) + bWasTimeoutMsg = (SAL_MSG_TIMER_CALLBACK == aMsg.message) + && static_cast<bool>( nRet ); + if ( bHandleAllCurrentEvents && !bHadNewerEvent && aMsg.time > nCurTicks && (nLastTicks <= nCurTicks || aMsg.time < nLastTicks) ) @@ -666,14 +667,16 @@ LRESULT CALLBACK SalComWndProc( HWND, UINT nMsg, WPARAM wParam, LPARAM lParam, i { WinSalTimer *const pTimer = static_cast<WinSalTimer*>( ImplGetSVData()->maSchedCtx.mpSalTimer ); assert( pTimer != nullptr ); - pTimer->ImplHandleTimerEvent( wParam ); + nRet = static_cast<LRESULT>( pTimer->ImplHandleTimerEvent( wParam ) ); + rDef = FALSE; break; } case WM_TIMER: { WinSalTimer *const pTimer = static_cast<WinSalTimer*>( ImplGetSVData()->maSchedCtx.mpSalTimer ); assert( pTimer != nullptr ); - pTimer->ImplHandle_WM_TIMER( wParam ); + nRet = static_cast<LRESULT>( pTimer->ImplHandle_WM_TIMER( wParam ) ); + rDef = FALSE; break; } } diff --git a/vcl/win/app/saltimer.cxx b/vcl/win/app/saltimer.cxx index 9d20c70bdb5a..9c67e841956e 100644 --- a/vcl/win/app/saltimer.cxx +++ b/vcl/win/app/saltimer.cxx @@ -158,13 +158,14 @@ void WinSalTimer::ImplHandleElapsedTimer() ImplSalYieldMutexRelease(); } -void WinSalTimer::ImplHandleTimerEvent( const WPARAM aWPARAM ) +bool WinSalTimer::ImplHandleTimerEvent( const WPARAM aWPARAM ) { assert( aWPARAM <= SAL_MAX_INT32 ); if ( !IsValidEventVersion( static_cast<sal_Int32>( aWPARAM ) ) ) - return; + return false; ImplHandleElapsedTimer(); + return true; } void WinSalTimer::SetForceRealTimer( const bool bVal ) @@ -179,11 +180,14 @@ void WinSalTimer::SetForceRealTimer( const bool bVal ) Start( 0 ); } -void WinSalTimer::ImplHandle_WM_TIMER( const WPARAM aWPARAM ) +bool WinSalTimer::ImplHandle_WM_TIMER( const WPARAM aWPARAM ) { assert( m_aWmTimerId == aWPARAM ); - if ( m_aWmTimerId == aWPARAM && m_bDirectTimeout && m_bForceRealTimer ) - ImplHandleElapsedTimer(); + if ( !(m_aWmTimerId == aWPARAM && m_bDirectTimeout && m_bForceRealTimer) ) + return false; + + ImplHandleElapsedTimer(); + return true; } /* vim:set shiftwidth=4 softtabstop=4 expandtab: */ |