VERY experimental Nintendo Switch 2 emulator
C++
core: hle: kernel: Allocate dummy threads on host thread storage.
bunnei8b109f8a6918
diff --git a/src/core/hle/kernel/kernel.cpp b/src/core/hle/kernel/kernel.cppindex 16d3a6cb4f..f9828bc43e 100644--- a/src/core/hle/kernel/kernel.cpp+++ b/src/core/hle/kernel/kernel.cpp@@ -283,15 +283,16 @@ struct KernelCore::Impl {// Gets the dummy KThread for the caller, allocating a new one if this is the first timeKThread* GetHostDummyThread() {- auto make_thread = [this]() {- KThread* thread = KThread::Create(system.Kernel());+ auto initialize = [this](KThread* thread) {ASSERT(KThread::InitializeDummyThread(thread).IsSuccess());thread->SetName(fmt::format("DummyThread:{}", GetHostThreadId()));return thread;};- thread_local KThread* saved_thread = make_thread();- return saved_thread;+ thread_local auto raw_thread = KThread(system.Kernel());+ thread_local auto thread = initialize(&raw_thread);++ return thread;}/// Registers a CPU core thread by allocating a host thread ID for itdiff --git a/src/core/hle/kernel/service_thread.cpp b/src/core/hle/kernel/service_thread.cppindex 4eb3a5988c..52d25b837b 100644--- a/src/core/hle/kernel/service_thread.cpp+++ b/src/core/hle/kernel/service_thread.cpp@@ -49,12 +49,9 @@ ServiceThread::Impl::Impl(KernelCore& kernel, std::size_t num_threads, const stdreturn;}+ // Allocate a dummy guest thread for this host thread.kernel.RegisterHostThread();- // Ensure the dummy thread allocated for this host thread is closed on exit.- auto* dummy_thread = kernel.GetCurrentEmuThread();- SCOPE_EXIT({ dummy_thread->Close(); });-while (true) {std::function<void()> task;