Skip to content

Commit

Permalink
Platform: Core: ignore emulator thread messages sent while the thread…
Browse files Browse the repository at this point in the history
… isn't running
  • Loading branch information
fleroviux committed Jan 14, 2024
1 parent db6802f commit ff39a47
Showing 1 changed file with 9 additions and 0 deletions.
9 changes: 9 additions & 0 deletions src/platform/core/src/emulator_thread.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -72,6 +72,9 @@ void EmulatorThread::Start(std::unique_ptr<CoreBase> core) {
frame_rate_cb(real_fps);
});
}

// Make sure all messages are handled before exiting
ProcessMessages();
}};
}

Expand All @@ -96,6 +99,12 @@ void EmulatorThread::SetKeyStatus(Key key, bool pressed) {
}

void EmulatorThread::PushMessage(const Message& message) {
// @todo: think of the best way to transparently handle messages
// sent while the emulator thread isn't running.
if(!IsRunning()) {
return;
}

std::lock_guard lock_guard{msg_queue_mutex};
msg_queue.push(message); // @todo: maybe use emplace.
}
Expand Down

0 comments on commit ff39a47

Please sign in to comment.