From 9046d4a5485452802b756869b7d27056ba9ea9d7 Mon Sep 17 00:00:00 2001 From: bunnei Date: Sun, 24 Nov 2019 20:15:51 -0500 Subject: kernel: Replace usage of boost::intrusive_ptr with std::shared_ptr for kernel objects. (#3154) * kernel: Replace usage of boost::intrusive_ptr with std::shared_ptr for kernel objects. - See https://github.com/citra-emu/citra/pull/4710 for details. --- src/core/hle/kernel/process.cpp | 33 +++++++++++++++++---------------- 1 file changed, 17 insertions(+), 16 deletions(-) (limited to 'src/core/hle/kernel/process.cpp') diff --git a/src/core/hle/kernel/process.cpp b/src/core/hle/kernel/process.cpp index a4e0dd385..12ea4ebe3 100644 --- a/src/core/hle/kernel/process.cpp +++ b/src/core/hle/kernel/process.cpp @@ -38,7 +38,7 @@ void SetupMainThread(Process& owner_process, KernelCore& kernel, u32 priority) { auto thread_res = Thread::Create(kernel, "main", entry_point, priority, 0, owner_process.GetIdealCore(), stack_top, owner_process); - SharedPtr thread = std::move(thread_res).Unwrap(); + std::shared_ptr thread = std::move(thread_res).Unwrap(); // Register 1 must be a handle to the main thread const Handle thread_handle = owner_process.GetHandleTable().Create(thread).Unwrap(); @@ -100,10 +100,10 @@ private: std::bitset is_slot_used; }; -SharedPtr Process::Create(Core::System& system, std::string name, ProcessType type) { +std::shared_ptr Process::Create(Core::System& system, std::string name, ProcessType type) { auto& kernel = system.Kernel(); - SharedPtr process(new Process(system)); + std::shared_ptr process = std::make_shared(system); process->name = std::move(name); process->resource_limit = kernel.GetSystemResourceLimit(); process->status = ProcessStatus::Created; @@ -121,7 +121,7 @@ SharedPtr Process::Create(Core::System& system, std::string name, Proce return process; } -SharedPtr Process::GetResourceLimit() const { +std::shared_ptr Process::GetResourceLimit() const { return resource_limit; } @@ -142,12 +142,12 @@ u64 Process::GetTotalPhysicalMemoryUsedWithoutSystemResource() const { return GetTotalPhysicalMemoryUsed() - GetSystemResourceUsage(); } -void Process::InsertConditionVariableThread(SharedPtr thread) { +void Process::InsertConditionVariableThread(std::shared_ptr thread) { VAddr cond_var_addr = thread->GetCondVarWaitAddress(); - std::list>& thread_list = cond_var_threads[cond_var_addr]; + std::list>& thread_list = cond_var_threads[cond_var_addr]; auto it = thread_list.begin(); while (it != thread_list.end()) { - const SharedPtr current_thread = *it; + const std::shared_ptr current_thread = *it; if (current_thread->GetPriority() > thread->GetPriority()) { thread_list.insert(it, thread); return; @@ -157,12 +157,12 @@ void Process::InsertConditionVariableThread(SharedPtr thread) { thread_list.push_back(thread); } -void Process::RemoveConditionVariableThread(SharedPtr thread) { +void Process::RemoveConditionVariableThread(std::shared_ptr thread) { VAddr cond_var_addr = thread->GetCondVarWaitAddress(); - std::list>& thread_list = cond_var_threads[cond_var_addr]; + std::list>& thread_list = cond_var_threads[cond_var_addr]; auto it = thread_list.begin(); while (it != thread_list.end()) { - const SharedPtr current_thread = *it; + const std::shared_ptr current_thread = *it; if (current_thread.get() == thread.get()) { thread_list.erase(it); return; @@ -172,12 +172,13 @@ void Process::RemoveConditionVariableThread(SharedPtr thread) { UNREACHABLE(); } -std::vector> Process::GetConditionVariableThreads(const VAddr cond_var_addr) { - std::vector> result{}; - std::list>& thread_list = cond_var_threads[cond_var_addr]; +std::vector> Process::GetConditionVariableThreads( + const VAddr cond_var_addr) { + std::vector> result{}; + std::list>& thread_list = cond_var_threads[cond_var_addr]; auto it = thread_list.begin(); while (it != thread_list.end()) { - SharedPtr current_thread = *it; + std::shared_ptr current_thread = *it; result.push_back(current_thread); ++it; } @@ -239,12 +240,12 @@ void Process::Run(s32 main_thread_priority, u64 stack_size) { void Process::PrepareForTermination() { ChangeStatus(ProcessStatus::Exiting); - const auto stop_threads = [this](const std::vector>& thread_list) { + const auto stop_threads = [this](const std::vector>& thread_list) { for (auto& thread : thread_list) { if (thread->GetOwnerProcess() != this) continue; - if (thread == system.CurrentScheduler().GetCurrentThread()) + if (thread.get() == system.CurrentScheduler().GetCurrentThread()) continue; // TODO(Subv): When are the other running/ready threads terminated? -- cgit v1.2.3