kernel/thread: Use a regular pointer for the owner/current process

There's no real need to use a shared pointer in these cases, and only
makes object management more fragile in terms of how easy it would be to
introduce cycles. Instead, just do the simple thing of using a regular
pointer. Much of this is just a hold-over from citra anyways.

It also doesn't make sense from a behavioral point of view for a
process' thread to prolong the lifetime of the process itself (the
process is supposed to own the thread, not the other way around).
This commit is contained in:
Lioncash 2018-10-10 00:42:10 -04:00
parent 5461b21c7a
commit 5c0408596f
10 changed files with 41 additions and 39 deletions

View file

@ -116,7 +116,7 @@ struct KernelCore::Impl {
next_thread_id = 1;
process_list.clear();
current_process.reset();
current_process = nullptr;
handle_table.Clear();
resource_limits.fill(nullptr);
@ -207,7 +207,7 @@ struct KernelCore::Impl {
// Lists all processes that exist in the current session.
std::vector<SharedPtr<Process>> process_list;
SharedPtr<Process> current_process;
Process* current_process = nullptr;
Kernel::HandleTable handle_table;
std::array<SharedPtr<ResourceLimit>, 4> resource_limits;
@ -266,15 +266,15 @@ 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);
void KernelCore::MakeCurrentProcess(Process* process) {
impl->current_process = process;
}
SharedPtr<Process>& KernelCore::CurrentProcess() {
Process* KernelCore::CurrentProcess() {
return impl->current_process;
}
const SharedPtr<Process>& KernelCore::CurrentProcess() const {
const Process* KernelCore::CurrentProcess() const {
return impl->current_process;
}