From 99104a25a81745ec7b3ae2aadf2733687159f2fe Mon Sep 17 00:00:00 2001 From: Ben Vanik Date: Wed, 15 Jul 2015 18:01:17 -0700 Subject: [PATCH] Fixing thread exit. --- src/xenia/base/threading.h | 12 ++++++------ src/xenia/base/threading_win.cc | 7 ++----- src/xenia/kernel/objects/xthread.cc | 2 +- 3 files changed, 9 insertions(+), 12 deletions(-) diff --git a/src/xenia/base/threading.h b/src/xenia/base/threading.h index 0116d6165..539fc228a 100644 --- a/src/xenia/base/threading.h +++ b/src/xenia/base/threading.h @@ -310,6 +310,12 @@ class Thread : public WaitHandle { static std::unique_ptr Create(CreationParameters params, std::function start_routine); + // Ends the calling thread. + // No destructors are called, and this function does not return. + // The state of the thread object becomes signaled, releasing any other + // threads that had been waiting for the thread to terminate. + static void Exit(int exit_code); + // Returns the current name of the thread, if previously specified. std::string name() const { return name_; } @@ -348,12 +354,6 @@ class Thread : public WaitHandle { // Suspends the specified thread. virtual bool Suspend(uint32_t* out_previous_suspend_count = nullptr) = 0; - // Ends the calling thread. - // No destructors are called, and this function does not return. - // The state of the thread object becomes signaled, releasing any other - // threads that had been waiting for the thread to terminate. - virtual void Exit(int exit_code) = 0; - // Terminates the thread. // No destructors are called, and this function does not return. // The state of the thread object becomes signaled, releasing any other diff --git a/src/xenia/base/threading_win.cc b/src/xenia/base/threading_win.cc index 3e7b18442..6f59b49b0 100644 --- a/src/xenia/base/threading_win.cc +++ b/src/xenia/base/threading_win.cc @@ -357,11 +357,6 @@ class Win32Thread : public Win32Handle { return true; } - void Exit(int exit_code) override { - AssertCallingThread(); - ExitThread(exit_code); - } - void Terminate(int exit_code) override { TerminateThread(handle_, exit_code); } @@ -399,5 +394,7 @@ std::unique_ptr Thread::Create(CreationParameters params, return std::make_unique(handle); } +void Thread::Exit(int exit_code) { ExitThread(exit_code); } + } // namespace threading } // namespace xe diff --git a/src/xenia/kernel/objects/xthread.cc b/src/xenia/kernel/objects/xthread.cc index 22cafcf2a..adfbafdce 100644 --- a/src/xenia/kernel/objects/xthread.cc +++ b/src/xenia/kernel/objects/xthread.cc @@ -377,7 +377,7 @@ X_STATUS XThread::Exit(int exit_code) { Release(); // NOTE: this does not return! - thread_->Exit(exit_code); + xe::threading::Thread::Exit(exit_code); return X_STATUS_SUCCESS; }