-// Yield to other processes
-
-bool wxApp::Yield(bool onlyIfNeeded)
-{
- if (s_inYield)
- {
- if ( !onlyIfNeeded )
- {
- wxFAIL_MSG( wxT("wxYield called recursively" ) );
- }
-
- return false;
- }
-
-#if wxUSE_THREADS
- // Yielding from a non-gui thread needs to bail out, otherwise we end up
- // possibly sending events in the thread too.
- if ( !wxThread::IsMain() )
- {
- return true;
- }
-#endif // wxUSE_THREADS
-
- s_inYield = true;
-
- // by definition yield should handle all non-processed events
-
- EventRef theEvent;
-
- OSStatus status = noErr ;
-
- while ( status == noErr )
- {
- s_inReceiveEvent = true ;
- status = ReceiveNextEvent(0, NULL,kEventDurationNoWait,true,&theEvent) ;
- s_inReceiveEvent = false ;
-
- if ( status == eventLoopTimedOutErr )
- {
- // make sure next time the event loop will trigger idle events
- sleepTime = kEventDurationNoWait ;
- }
- else if ( status == eventLoopQuitErr )
- {
- // according to QA1061 this may also occur when a WakeUp Process
- // is executed
- }
- else
- {
- MacHandleOneEvent( theEvent ) ;
- ReleaseEvent(theEvent);
- }
- }
-
- s_inYield = false;
-
- return true;
-}
-
-void wxApp::MacDoOneEvent()
-{
- wxMacAutoreleasePool autoreleasepool;
- EventRef theEvent;
-
- s_inReceiveEvent = true ;
- OSStatus status = ReceiveNextEvent(0, NULL, sleepTime, true, &theEvent) ;
- s_inReceiveEvent = false ;
-
- switch (status)
- {
- case eventLoopTimedOutErr :
- if ( wxTheApp->ProcessIdle() )
- sleepTime = kEventDurationNoWait ;
- else
- sleepTime = kEventDurationSecond;
- break;
-
- case eventLoopQuitErr :
- // according to QA1061 this may also occur
- // when a WakeUp Process is executed
- break;
-
- default:
- MacHandleOneEvent( theEvent ) ;
- ReleaseEvent( theEvent );
- sleepTime = kEventDurationNoWait ;
- break;
- }
- // repeaters
-
- DeletePendingObjects() ;
-}
-