diff --git a/src/core/hle/kernel/thread.cpp b/src/core/hle/kernel/thread.cpp index 1c835f601d..80cbe789a7 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 6c9df27ff4..759332254d 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 {