Kaydet (Commit) 47ee8098 authored tarafından Jan-Marek Glogowski's avatar Jan-Marek Glogowski

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/43529Tested-by: 's avatarJenkins <ci@libreoffice.org>
Reviewed-by: 's avatarJan-Marek Glogowski <glogow@fbihome.de>
üst 9466ea1a
......@@ -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
......
......@@ -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();
......
......@@ -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;
}
}
......
......@@ -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: */
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment