Fix another race condition.

If EVENT_FINISH is received, but coreState is still CORE_RUNNING and the
thread is still enabled, it would hang.  Makes more sense to wait for
events before processing them anyhow...
This commit is contained in:
Unknown W. Brackets committed 2014-04-28 22:12:33 -07:00
1 parent a5b27b659c
commit effcee475b
1 file changed
+4 -5
+4 -5
View File
@@ -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.