From 876729ab525a6298468bf7c4760c910309a0d5eb Mon Sep 17 00:00:00 2001 From: Weiyi Wang Date: Tue, 23 Oct 2018 10:32:23 -0400 Subject: [PATCH] kernel/thread: move next_thread_id into manager --- src/core/hle/kernel/thread.cpp | 12 ++---------- src/core/hle/kernel/thread.h | 8 ++++++++ 2 files changed, 10 insertions(+), 10 deletions(-) diff --git a/src/core/hle/kernel/thread.cpp b/src/core/hle/kernel/thread.cpp index 1c835f601..80cbe789a 100644 --- a/src/core/hle/kernel/thread.cpp +++ b/src/core/hle/kernel/thread.cpp @@ -48,14 +48,7 @@ static Common::ThreadQueueList ready_queue; static SharedPtr current_thread; -// The first available thread id at startup -static u32 next_thread_id; - -/** - * Creates a new thread ID - * @return The new thread ID - */ -inline static u32 const NewThreadId() { +u32 ThreadManager::NewThreadId() { return next_thread_id++; } @@ -348,7 +341,7 @@ ResultVal> KernelSystem::CreateThread(std::string name, VAddr thread_list.push_back(thread); ready_queue.prepare(priority); - thread->thread_id = NewThreadId(); + thread->thread_id = thread_manager->NewThreadId(); thread->status = ThreadStatus::Dormant; thread->entry_point = entry_point; thread->stack_top = stack_top; @@ -504,7 +497,6 @@ void ThreadingInit() { ThreadWakeupEventType = CoreTiming::RegisterEvent("ThreadWakeupCallback", ThreadWakeupCallback); current_thread = nullptr; - next_thread_id = 1; } void ThreadingShutdown() { diff --git a/src/core/hle/kernel/thread.h b/src/core/hle/kernel/thread.h index 6c9df27ff..759332254 100644 --- a/src/core/hle/kernel/thread.h +++ b/src/core/hle/kernel/thread.h @@ -55,6 +55,14 @@ enum class ThreadWakeupReason { class ThreadManager { public: + /** + * Creates a new thread ID + * @return The new thread ID + */ + u32 NewThreadId(); + +private: + u32 next_thread_id = 1; }; class Thread final : public WaitObject {