summaryrefslogtreecommitdiff
path: root/vcl
diff options
context:
space:
mode:
authorPhilipp Lohmann [pl] <Philipp.Lohmann@Sun.COM>2010-03-23 16:18:47 +0100
committerPhilipp Lohmann [pl] <Philipp.Lohmann@Sun.COM>2010-03-23 16:18:47 +0100
commitdd69e7d54931e7510482a35a0a605f0c8792ee7c (patch)
tree13a5673dcb64ce6a38c901920d41c531d52cc9a2 /vcl
parent10bd32766e95739de595cc4f99375020846e16b9 (diff)
vcl110: #i103162# avoid busy loop in non mainthread execute
Diffstat (limited to 'vcl')
-rw-r--r--vcl/unx/gtk/app/gtkdata.cxx21
1 files changed, 9 insertions, 12 deletions
diff --git a/vcl/unx/gtk/app/gtkdata.cxx b/vcl/unx/gtk/app/gtkdata.cxx
index b1529e060270..0b3e443c40ec 100644
--- a/vcl/unx/gtk/app/gtkdata.cxx
+++ b/vcl/unx/gtk/app/gtkdata.cxx
@@ -800,15 +800,12 @@ void GtkXLib::Yield( bool bWait, bool bHandleAllCurrentEvents )
*/
bool bDispatchThread = false;
+ gboolean wasEvent = FALSE;
{
// release YieldMutex (and re-acquire at block end)
YieldMutexReleaser aReleaser;
if( osl_tryToAcquireMutex( m_aDispatchMutex ) )
- {
- // we are the dispatch thread
- osl_resetCondition( m_aDispatchCondition );
bDispatchThread = true;
- }
else if( ! bWait )
return; // someone else is waiting already, return
@@ -816,7 +813,7 @@ void GtkXLib::Yield( bool bWait, bool bHandleAllCurrentEvents )
if( bDispatchThread )
{
int nMaxEvents = bHandleAllCurrentEvents ? 100 : 1;
- gboolean wasEvent = FALSE, wasOneEvent = TRUE;
+ gboolean wasOneEvent = TRUE;
while( nMaxEvents-- && wasOneEvent )
{
wasOneEvent = g_main_context_iteration( NULL, FALSE );
@@ -824,17 +821,17 @@ void GtkXLib::Yield( bool bWait, bool bHandleAllCurrentEvents )
wasEvent = TRUE;
}
if( bWait && ! wasEvent )
- g_main_context_iteration( NULL, TRUE );
+ wasEvent = g_main_context_iteration( NULL, TRUE );
}
- else if( userEventFn( this ) )
+ else if( bWait )
{
/* #i41693# in case the dispatch thread hangs in join
* for this thread the condition will never be set
* workaround: timeout of 1 second a emergency exit
*/
- TimeValue aValue;
- aValue.Seconds = 1;
- aValue.Nanosec = 0;
+ // we are the dispatch thread
+ osl_resetCondition( m_aDispatchCondition );
+ TimeValue aValue = { 1, 0 };
osl_waitCondition( m_aDispatchCondition, &aValue );
}
}
@@ -842,8 +839,8 @@ void GtkXLib::Yield( bool bWait, bool bHandleAllCurrentEvents )
if( bDispatchThread )
{
osl_releaseMutex( m_aDispatchMutex );
- osl_setCondition( m_aDispatchCondition ); // trigger non dispatch thread yields
- osl_resetCondition( m_aDispatchCondition );
+ if( wasEvent )
+ osl_setCondition( m_aDispatchCondition ); // trigger non dispatch thread yields
}
}