mirror of
https://github.com/citra-emu/citra.git
synced 2024-11-23 22:20:10 +00:00
Thread: Move StopThread to a member function
This commit is contained in:
parent
4637df2721
commit
eae3d8e6d8
@ -121,29 +121,24 @@ static bool CheckWaitType(const Thread* thread, WaitType type, Handle wait_handl
|
||||
}
|
||||
|
||||
/// Stops the current thread
|
||||
ResultCode StopThread(Handle handle, const char* reason) {
|
||||
Thread* thread = g_handle_table.Get<Thread>(handle);
|
||||
if (thread == nullptr) return InvalidHandle(ErrorModule::Kernel);
|
||||
|
||||
void Thread::Stop(const char* reason) {
|
||||
// Release all the mutexes that this thread holds
|
||||
ReleaseThreadMutexes(handle);
|
||||
ReleaseThreadMutexes(GetHandle());
|
||||
|
||||
ChangeReadyState(thread, false);
|
||||
thread->status = THREADSTATUS_DORMANT;
|
||||
for (Handle waiting_handle : thread->waiting_threads) {
|
||||
ChangeReadyState(this, false);
|
||||
status = THREADSTATUS_DORMANT;
|
||||
for (Handle waiting_handle : waiting_threads) {
|
||||
Thread* waiting_thread = g_handle_table.Get<Thread>(waiting_handle);
|
||||
|
||||
if (CheckWaitType(waiting_thread, WAITTYPE_THREADEND, handle))
|
||||
if (CheckWaitType(waiting_thread, WAITTYPE_THREADEND, GetHandle()))
|
||||
ResumeThreadFromWait(waiting_handle);
|
||||
}
|
||||
thread->waiting_threads.clear();
|
||||
waiting_threads.clear();
|
||||
|
||||
// Stopped threads are never waiting.
|
||||
thread->wait_type = WAITTYPE_NONE;
|
||||
thread->wait_handle = 0;
|
||||
thread->wait_address = 0;
|
||||
|
||||
return RESULT_SUCCESS;
|
||||
wait_type = WAITTYPE_NONE;
|
||||
wait_handle = 0;
|
||||
wait_address = 0;
|
||||
}
|
||||
|
||||
/// Changes a threads state
|
||||
|
@ -75,6 +75,8 @@ public:
|
||||
|
||||
u32 GetThreadId() const { return thread_id; }
|
||||
|
||||
void Stop(const char* reason);
|
||||
|
||||
Core::ThreadContext context;
|
||||
|
||||
u32 thread_id;
|
||||
@ -107,9 +109,6 @@ Thread* SetupMainThread(s32 priority, int stack_size = Kernel::DEFAULT_STACK_SIZ
|
||||
/// Reschedules to the next available thread (call after current thread is suspended)
|
||||
void Reschedule();
|
||||
|
||||
/// Stops the current thread
|
||||
ResultCode StopThread(Handle thread, const char* reason);
|
||||
|
||||
/// Resumes a thread from waiting by marking it as "ready"
|
||||
void ResumeThreadFromWait(Handle handle);
|
||||
|
||||
|
@ -245,14 +245,11 @@ static Result CreateThread(u32 priority, u32 entry_point, u32 arg, u32 stack_top
|
||||
}
|
||||
|
||||
/// Called when a thread exits
|
||||
static u32 ExitThread() {
|
||||
Handle thread = Kernel::GetCurrentThread()->GetHandle();
|
||||
static void ExitThread() {
|
||||
LOG_TRACE(Kernel_SVC, "called, pc=0x%08X", Core::g_app_core->GetPC());
|
||||
|
||||
LOG_TRACE(Kernel_SVC, "called, pc=0x%08X", Core::g_app_core->GetPC()); // PC = 0x0010545C
|
||||
|
||||
Kernel::StopThread(thread, __func__);
|
||||
Kernel::GetCurrentThread()->Stop(__func__);
|
||||
HLE::Reschedule(__func__);
|
||||
return 0;
|
||||
}
|
||||
|
||||
/// Gets the priority for the specified thread
|
||||
@ -389,7 +386,7 @@ const HLE::FunctionDef SVC_Table[] = {
|
||||
{0x06, nullptr, "GetProcessIdealProcessor"},
|
||||
{0x07, nullptr, "SetProcessIdealProcessor"},
|
||||
{0x08, HLE::Wrap<CreateThread>, "CreateThread"},
|
||||
{0x09, HLE::Wrap<ExitThread>, "ExitThread"},
|
||||
{0x09, ExitThread, "ExitThread"},
|
||||
{0x0A, HLE::Wrap<SleepThread>, "SleepThread"},
|
||||
{0x0B, HLE::Wrap<GetThreadPriority>, "GetThreadPriority"},
|
||||
{0x0C, HLE::Wrap<SetThreadPriority>, "SetThreadPriority"},
|
||||
|
Loading…
Reference in New Issue
Block a user