From c91d2e959b44d424041d368ea87e7ff9a1c3bcd5 Mon Sep 17 00:00:00 2001 From: Yuri Kunde Schlesner Date: Mon, 22 Dec 2014 13:00:58 -0200 Subject: [PATCH] Thread: Remove the last Handle-based interfaces from Thread.cpp --- src/core/hle/kernel/address_arbiter.cpp | 4 ++-- src/core/hle/kernel/thread.cpp | 19 +++++++++---------- src/core/hle/kernel/thread.h | 4 ++-- 3 files changed, 13 insertions(+), 14 deletions(-) diff --git a/src/core/hle/kernel/address_arbiter.cpp b/src/core/hle/kernel/address_arbiter.cpp index 7f8532425..2f5ccac09 100644 --- a/src/core/hle/kernel/address_arbiter.cpp +++ b/src/core/hle/kernel/address_arbiter.cpp @@ -40,11 +40,11 @@ ResultCode ArbitrateAddress(Handle handle, ArbitrationType type, u32 address, s3 case ArbitrationType::Signal: // Negative value means resume all threads if (value < 0) { - ArbitrateAllThreads(handle, address); + ArbitrateAllThreads(object, address); } else { // Resume first N threads for(int i = 0; i < value; i++) - ArbitrateHighestPriorityThread(handle, address); + ArbitrateHighestPriorityThread(object, address); } break; diff --git a/src/core/hle/kernel/thread.cpp b/src/core/hle/kernel/thread.cpp index 95ec42c10..dadbd7242 100644 --- a/src/core/hle/kernel/thread.cpp +++ b/src/core/hle/kernel/thread.cpp @@ -152,39 +152,38 @@ void ChangeThreadState(Thread* t, ThreadStatus new_status) { } /// Arbitrate the highest priority thread that is waiting -Handle ArbitrateHighestPriorityThread(Handle arbiter, u32 address) { - Handle highest_priority_thread = 0; +Thread* ArbitrateHighestPriorityThread(Object* arbiter, u32 address) { + Thread* highest_priority_thread = nullptr; s32 priority = THREADPRIO_LOWEST; // Iterate through threads, find highest priority thread that is waiting to be arbitrated... for (Thread* thread : thread_queue) { - if (!CheckWaitType(thread, WAITTYPE_ARB, Kernel::g_handle_table.GetGeneric(arbiter), address)) + if (!CheckWaitType(thread, WAITTYPE_ARB, arbiter, address)) continue; if (thread == nullptr) continue; // TODO(yuriks): Thread handle will hang around forever. Should clean up. if(thread->current_priority <= priority) { - highest_priority_thread = thread->GetHandle(); + highest_priority_thread = thread; priority = thread->current_priority; } } + // If a thread was arbitrated, resume it - if (0 != highest_priority_thread) { - Thread* thread = Kernel::g_handle_table.Get(highest_priority_thread); - if (thread != nullptr) - thread->ResumeFromWait(); + if (nullptr != highest_priority_thread) { + highest_priority_thread->ResumeFromWait(); } return highest_priority_thread; } /// Arbitrate all threads currently waiting -void ArbitrateAllThreads(Handle arbiter, u32 address) { +void ArbitrateAllThreads(Object* arbiter, u32 address) { // Iterate through threads, find highest priority thread that is waiting to be arbitrated... for (Thread* thread : thread_queue) { - if (CheckWaitType(thread, WAITTYPE_ARB, Kernel::g_handle_table.GetGeneric(arbiter), address)) + if (CheckWaitType(thread, WAITTYPE_ARB, arbiter, address)) thread->ResumeFromWait(); } } diff --git a/src/core/hle/kernel/thread.h b/src/core/hle/kernel/thread.h index 2cd8606d9..a89fd6265 100644 --- a/src/core/hle/kernel/thread.h +++ b/src/core/hle/kernel/thread.h @@ -112,10 +112,10 @@ Thread* SetupMainThread(s32 priority, int stack_size = Kernel::DEFAULT_STACK_SIZ void Reschedule(); /// Arbitrate the highest priority thread that is waiting -Handle ArbitrateHighestPriorityThread(Handle arbiter, u32 address); +Thread* ArbitrateHighestPriorityThread(Object* arbiter, u32 address); /// Arbitrate all threads currently waiting... -void ArbitrateAllThreads(Handle arbiter, u32 address); +void ArbitrateAllThreads(Object* arbiter, u32 address); /// Gets the current thread Thread* GetCurrentThread();