diff options
author | Lioncash <mathew1800@gmail.com> | 2018-09-06 20:34:51 -0400 |
---|---|---|
committer | Lioncash <mathew1800@gmail.com> | 2018-09-06 20:52:58 -0400 |
commit | 3f17fe71334a27a60bf54adc55eabe2356ed31f5 (patch) | |
tree | 11fd2e48608908feb95c9024e3bd8e1267ec538a /src/core/hle/kernel/kernel.cpp | |
parent | a164b413fa479ec1ab0322044ca5ce6c16708e3a (diff) |
core: Migrate current_process pointer to the kernel
Given we now have the kernel as a class, it doesn't make sense to keep
the current process pointer within the System class, as processes are
related to the kernel.
This also gets rid of a subtle case where memory wouldn't be freed on
core shutdown, as the current_process pointer would never be reset,
causing the pointed to contents to continue to live.
Diffstat (limited to 'src/core/hle/kernel/kernel.cpp')
-rw-r--r-- | src/core/hle/kernel/kernel.cpp | 14 |
1 files changed, 14 insertions, 0 deletions
diff --git a/src/core/hle/kernel/kernel.cpp b/src/core/hle/kernel/kernel.cpp index 7902c28829..3e0800a716 100644 --- a/src/core/hle/kernel/kernel.cpp +++ b/src/core/hle/kernel/kernel.cpp @@ -116,6 +116,7 @@ struct KernelCore::Impl { next_thread_id = 1; process_list.clear(); + current_process.reset(); handle_table.Clear(); resource_limits.fill(nullptr); @@ -206,6 +207,7 @@ struct KernelCore::Impl { // Lists all processes that exist in the current session. std::vector<SharedPtr<Process>> process_list; + SharedPtr<Process> current_process; Kernel::HandleTable handle_table; std::array<SharedPtr<ResourceLimit>, 4> resource_limits; @@ -264,6 +266,18 @@ void KernelCore::AppendNewProcess(SharedPtr<Process> process) { impl->process_list.push_back(std::move(process)); } +void KernelCore::MakeCurrentProcess(SharedPtr<Process> process) { + impl->current_process = std::move(process); +} + +SharedPtr<Process>& KernelCore::CurrentProcess() { + return impl->current_process; +} + +const SharedPtr<Process>& KernelCore::CurrentProcess() const { + return impl->current_process; +} + void KernelCore::AddNamedPort(std::string name, SharedPtr<ClientPort> port) { impl->named_ports.emplace(std::move(name), std::move(port)); } |