mirror of
https://github.com/hrydgard/ppsspp.git
synced 2026-11-29 09:13:39 +01:00
Fix hang on stop before run w/ multithreading.
And clarify logic.
This commit is contained in:
1 parent
d97c229eaf
commit
e08fbfd0af
1 file changed
+17
-1
+17
-1
@@ -112,6 +112,22 @@ struct ThreadEventQueue : public B {
|
||||
eventsHaveRun_ = false;
|
||||
}
|
||||
|
||||
inline bool ShouldSyncThread(bool force) {
|
||||
if (!HasEvents())
|
||||
return false;
|
||||
if (coreState != CORE_RUNNING && !force)
|
||||
return false;
|
||||
|
||||
// Don't run if it's not running, but wait for startup.
|
||||
if (!eventsRunning_) {
|
||||
if (eventsHaveRun_ || coreState == CORE_ERROR || coreState == CORE_POWERDOWN) {
|
||||
return false;
|
||||
}
|
||||
}
|
||||
|
||||
return true;
|
||||
}
|
||||
|
||||
// Force ignores coreState.
|
||||
void SyncThread(bool force = false) {
|
||||
if (!threadEnabled_) {
|
||||
@@ -122,7 +138,7 @@ struct ThreadEventQueue : public B {
|
||||
// While processing the last event, HasEvents() will be false even while not done.
|
||||
// So we schedule a nothing event and wait for that to finish.
|
||||
ScheduleEvent(EVENT_SYNC);
|
||||
while (HasEvents() && (eventsRunning_ || !eventsHaveRun_) && (force || coreState == CORE_RUNNING)) {
|
||||
while (ShouldSyncThread(force)) {
|
||||
eventsDrain_.wait(eventsLock_);
|
||||
}
|
||||
}
|
||||
|
||||
Reference in new issue
Block a user