[Core] Keep a reference to the main thread's XThread rather than its underlying thread.

This commit is contained in:
gibbed 2019-07-29 13:24:36 -05:00
parent a4d2f5e4ed
commit ecf64d8e05
2 changed files with 7 additions and 7 deletions

View File

@ -63,7 +63,7 @@ Emulator::Emulator(const std::wstring& command_line,
export_resolver_(),
file_system_(),
kernel_state_(),
main_thread_(nullptr),
main_thread_(),
title_id_(0),
paused_(false),
restoring_(false),
@ -472,7 +472,7 @@ bool Emulator::RestoreFromFile(const std::wstring& path) {
kernel_state_->object_table()->GetObjectsByType<kernel::XThread>();
for (auto thread : threads) {
if (thread->main_thread()) {
main_thread_ = thread->thread();
main_thread_ = thread;
break;
}
}
@ -574,7 +574,7 @@ bool Emulator::ExceptionCallback(Exception* ex) {
void Emulator::WaitUntilExit() {
while (true) {
xe::threading::Wait(main_thread_, false);
xe::threading::Wait(main_thread_->thread(), false);
if (restoring_) {
restore_fence_.Wait();
@ -659,12 +659,12 @@ X_STATUS Emulator::CompleteLaunch(const std::wstring& path,
}
}
auto main_xthread = kernel_state_->LaunchModule(module);
if (!main_xthread) {
auto main_thread = kernel_state_->LaunchModule(module);
if (!main_thread) {
return X_STATUS_UNSUCCESSFUL;
}
main_thread_ = main_xthread->thread();
main_thread_ = main_thread;
on_launch();
return X_STATUS_SUCCESS;

View File

@ -175,7 +175,7 @@ class Emulator {
std::unique_ptr<vfs::VirtualFileSystem> file_system_;
std::unique_ptr<kernel::KernelState> kernel_state_;
threading::Thread* main_thread_;
kernel::object_ref<kernel::XThread> main_thread_;
uint32_t title_id_; // Currently running title ID
bool paused_;