diff options
author | bunnei <bunneidev@gmail.com> | 2020-12-15 09:41:48 +0100 |
---|---|---|
committer | bunnei <bunneidev@gmail.com> | 2020-12-29 10:12:39 +0100 |
commit | dfdac7d38af170683812f3b474ef9d686dfa9ef8 (patch) | |
tree | d72ff3fb593e6d42984b4d89863ae22cab3d77f5 /src/core/hle/kernel/kernel.cpp | |
parent | hle: kernel: service_thread: Add thread name and take weak_ptr of ServerSession. (diff) | |
download | yuzu-dfdac7d38af170683812f3b474ef9d686dfa9ef8.tar yuzu-dfdac7d38af170683812f3b474ef9d686dfa9ef8.tar.gz yuzu-dfdac7d38af170683812f3b474ef9d686dfa9ef8.tar.bz2 yuzu-dfdac7d38af170683812f3b474ef9d686dfa9ef8.tar.lz yuzu-dfdac7d38af170683812f3b474ef9d686dfa9ef8.tar.xz yuzu-dfdac7d38af170683812f3b474ef9d686dfa9ef8.tar.zst yuzu-dfdac7d38af170683812f3b474ef9d686dfa9ef8.zip |
Diffstat (limited to 'src/core/hle/kernel/kernel.cpp')
-rw-r--r-- | src/core/hle/kernel/kernel.cpp | 21 |
1 files changed, 20 insertions, 1 deletions
diff --git a/src/core/hle/kernel/kernel.cpp b/src/core/hle/kernel/kernel.cpp index 312c64c17..5f917686f 100644 --- a/src/core/hle/kernel/kernel.cpp +++ b/src/core/hle/kernel/kernel.cpp @@ -8,7 +8,7 @@ #include <functional> #include <memory> #include <thread> -#include <unordered_map> +#include <unordered_set> #include <utility> #include "common/assert.h" @@ -35,6 +35,7 @@ #include "core/hle/kernel/physical_core.h" #include "core/hle/kernel/process.h" #include "core/hle/kernel/resource_limit.h" +#include "core/hle/kernel/service_thread.h" #include "core/hle/kernel/shared_memory.h" #include "core/hle/kernel/synchronization.h" #include "core/hle/kernel/thread.h" @@ -107,6 +108,9 @@ struct KernelCore::Impl { std::fill(register_host_thread_keys.begin(), register_host_thread_keys.end(), std::thread::id{}); std::fill(register_host_thread_values.begin(), register_host_thread_values.end(), 0); + + // Ensures all service threads gracefully shutdown + service_threads.clear(); } void InitializePhysicalCores() { @@ -345,6 +349,9 @@ struct KernelCore::Impl { std::shared_ptr<Kernel::SharedMemory> irs_shared_mem; std::shared_ptr<Kernel::SharedMemory> time_shared_mem; + // Threads used for services + std::unordered_set<std::shared_ptr<Kernel::ServiceThread>> service_threads; + std::array<std::shared_ptr<Thread>, Core::Hardware::NUM_CPU_CORES> suspend_threads{}; std::array<Core::CPUInterruptHandler, Core::Hardware::NUM_CPU_CORES> interrupts{}; std::array<std::unique_ptr<Kernel::KScheduler>, Core::Hardware::NUM_CPU_CORES> schedulers{}; @@ -639,4 +646,16 @@ void KernelCore::ExitSVCProfile() { MicroProfileLeave(MICROPROFILE_TOKEN(Kernel_SVC), impl->svc_ticks[core]); } +std::weak_ptr<Kernel::ServiceThread> KernelCore::CreateServiceThread(const std::string& name) { + auto service_thread = std::make_shared<Kernel::ServiceThread>(*this, 1, name); + impl->service_threads.emplace(service_thread); + return service_thread; +} + +void KernelCore::ReleaseServiceThread(std::weak_ptr<Kernel::ServiceThread> service_thread) { + if (auto strong_ptr = service_thread.lock()) { + impl->service_threads.erase(strong_ptr); + } +} + } // namespace Kernel |