diff --git a/Core/ThreadEventQueue.h b/Core/ThreadEventQueue.h index f18a2df4f1..3d594f52e6 100644 --- a/Core/ThreadEventQueue.h +++ b/Core/ThreadEventQueue.h @@ -75,6 +75,10 @@ struct ThreadEventQueue : public B { eventsHaveRun_ = true; do { + if (!HasEvents()) { + eventsWait_.wait(eventsLock_); + } + for (Event ev = GetNextEvent(); EventType(ev) != EVENT_INVALID; ev = GetNextEvent()) { eventsLock_.unlock(); switch (EventType(ev)) { @@ -96,11 +100,6 @@ struct ThreadEventQueue : public B { if (ShouldExitEventLoop() || !threadEnabled_) { break; } - - // coreState changes won't wake us, so recheck periodically. - if (!HasEvents()) { - eventsWait_.wait(eventsLock_); - } } while (CoreTiming::GetTicks() < globalticks); // This will force the waiter to check coreState, even if we didn't actually drain.