From 5619e790b81387a596004e90550ded34d667d3d5 Mon Sep 17 00:00:00 2001 From: Yuri Kunde Schlesner Date: Mon, 22 Dec 2014 13:00:11 -0200 Subject: [PATCH] Thread: Convert thread_ready_queue to pointers --- src/core/hle/kernel/thread.cpp | 19 +++++++++---------- 1 file changed, 9 insertions(+), 10 deletions(-) diff --git a/src/core/hle/kernel/thread.cpp b/src/core/hle/kernel/thread.cpp index f2fe5cbf8..95ec42c10 100644 --- a/src/core/hle/kernel/thread.cpp +++ b/src/core/hle/kernel/thread.cpp @@ -38,7 +38,7 @@ ResultVal Thread::WaitSynchronization() { static std::vector thread_queue; // TODO(yuriks): Owned // Lists only ready thread ids. -static Common::ThreadQueueList thread_ready_queue; +static Common::ThreadQueueList thread_ready_queue; static Thread* current_thread; @@ -88,16 +88,15 @@ void ResetThread(Thread* t, u32 arg, s32 lowest_priority) { /// Change a thread to "ready" state void ChangeReadyState(Thread* t, bool ready) { - Handle handle = t->GetHandle(); if (t->IsReady()) { if (!ready) { - thread_ready_queue.remove(t->current_priority, handle); + thread_ready_queue.remove(t->current_priority, t); } } else if (ready) { if (t->IsRunning()) { - thread_ready_queue.push_front(t->current_priority, handle); + thread_ready_queue.push_front(t->current_priority, t); } else { - thread_ready_queue.push_back(t->current_priority, handle); + thread_ready_queue.push_back(t->current_priority, t); } t->status = THREADSTATUS_READY; } @@ -225,7 +224,7 @@ void SwitchContext(Thread* t) { /// Gets the next thread that is ready to be run by priority Thread* NextThread() { - Handle next; + Thread* next; Thread* cur = GetCurrentThread(); if (cur && cur->IsRunning()) { @@ -236,7 +235,7 @@ Thread* NextThread() { if (next == 0) { return nullptr; } - return Kernel::g_handle_table.Get(next); + return next; } void WaitCurrentThread(WaitType wait_type, Object* wait_object) { @@ -269,7 +268,7 @@ void DebugThreadQueue() { } LOG_DEBUG(Kernel, "0x%02X 0x%08X (current)", thread->current_priority, GetCurrentThread()->GetHandle()); for (Thread* t : thread_queue) { - s32 priority = thread_ready_queue.contains(t->GetHandle()); + s32 priority = thread_ready_queue.contains(t); if (priority != -1) { LOG_DEBUG(Kernel, "0x%02X 0x%08X", priority, t->GetHandle()); } @@ -346,7 +345,7 @@ void Thread::SetPriority(s32 priority) { // Change thread priority s32 old = current_priority; - thread_ready_queue.remove(old, GetHandle()); + thread_ready_queue.remove(old, this); current_priority = priority; thread_ready_queue.prepare(current_priority); @@ -355,7 +354,7 @@ void Thread::SetPriority(s32 priority) { status = (status & ~THREADSTATUS_RUNNING) | THREADSTATUS_READY; } if (IsReady()) { - thread_ready_queue.push_back(current_priority, GetHandle()); + thread_ready_queue.push_back(current_priority, this); } }