void MessageManager::runDispatchLoop() { jassert (isThisTheMessageThread()); // must only be called by the message thread while (! quitMessageReceived) { JUCE_TRY { if (! dispatchNextMessageOnSystemQueue (false)) Thread::sleep (1); } JUCE_CATCH_EXCEPTION } }
bool MessageManager::runDispatchLoopUntil (int millisecondsToRunFor) { jassert (isThisTheMessageThread()); // must only be called by the message thread const int64 endTime = Time::currentTimeMillis() + millisecondsToRunFor; while (! quitMessageReceived) { JUCE_TRY { if (! dispatchNextMessageOnSystemQueue (millisecondsToRunFor >= 0)) Thread::sleep (1); } JUCE_CATCH_EXCEPTION if (millisecondsToRunFor >= 0 && Time::currentTimeMillis() >= endTime) break; } return ! quitMessageReceived; }
bool MessageManager::runDispatchLoopUntil (int millisecondsToRunFor) { jassert (isThisTheMessageThread()); // must only be called by the message thread const int64 endTime = Time::currentTimeMillis() + millisecondsToRunFor; while ((millisecondsToRunFor < 0 || endTime > Time::currentTimeMillis()) && ! quitMessageReceived) { JUCE_TRY { if (! dispatchNextMessageOnSystemQueue (millisecondsToRunFor >= 0)) { const int msToWait = (int) (endTime - Time::currentTimeMillis()); if (msToWait > 0) Thread::sleep (jmin (5, msToWait)); } } JUCE_CATCH_EXCEPTION } return ! quitMessageReceived; }