diff options
| author | 2019-11-24 20:15:51 -0500 | |
|---|---|---|
| committer | 2019-11-24 20:15:51 -0500 | |
| commit | 9046d4a5485452802b756869b7d27056ba9ea9d7 (patch) | |
| tree | 2d704d912e9054fb232b73ad69f1bc3966ed97a5 /src/core/hle/kernel/process.cpp | |
| parent | Merge pull request #3098 from ReinUsesLisp/shader-invalidations (diff) | |
| download | yuzu-9046d4a5485452802b756869b7d27056ba9ea9d7.tar.gz yuzu-9046d4a5485452802b756869b7d27056ba9ea9d7.tar.xz yuzu-9046d4a5485452802b756869b7d27056ba9ea9d7.zip | |
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.
Diffstat (limited to 'src/core/hle/kernel/process.cpp')
| -rw-r--r-- | src/core/hle/kernel/process.cpp | 33 |
1 files changed, 17 insertions, 16 deletions
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) { | |||
| 38 | auto thread_res = Thread::Create(kernel, "main", entry_point, priority, 0, | 38 | auto thread_res = Thread::Create(kernel, "main", entry_point, priority, 0, |
| 39 | owner_process.GetIdealCore(), stack_top, owner_process); | 39 | owner_process.GetIdealCore(), stack_top, owner_process); |
| 40 | 40 | ||
| 41 | SharedPtr<Thread> thread = std::move(thread_res).Unwrap(); | 41 | std::shared_ptr<Thread> thread = std::move(thread_res).Unwrap(); |
| 42 | 42 | ||
| 43 | // Register 1 must be a handle to the main thread | 43 | // Register 1 must be a handle to the main thread |
| 44 | const Handle thread_handle = owner_process.GetHandleTable().Create(thread).Unwrap(); | 44 | const Handle thread_handle = owner_process.GetHandleTable().Create(thread).Unwrap(); |
| @@ -100,10 +100,10 @@ private: | |||
| 100 | std::bitset<num_slot_entries> is_slot_used; | 100 | std::bitset<num_slot_entries> is_slot_used; |
| 101 | }; | 101 | }; |
| 102 | 102 | ||
| 103 | SharedPtr<Process> Process::Create(Core::System& system, std::string name, ProcessType type) { | 103 | std::shared_ptr<Process> Process::Create(Core::System& system, std::string name, ProcessType type) { |
| 104 | auto& kernel = system.Kernel(); | 104 | auto& kernel = system.Kernel(); |
| 105 | 105 | ||
| 106 | SharedPtr<Process> process(new Process(system)); | 106 | std::shared_ptr<Process> process = std::make_shared<Process>(system); |
| 107 | process->name = std::move(name); | 107 | process->name = std::move(name); |
| 108 | process->resource_limit = kernel.GetSystemResourceLimit(); | 108 | process->resource_limit = kernel.GetSystemResourceLimit(); |
| 109 | process->status = ProcessStatus::Created; | 109 | process->status = ProcessStatus::Created; |
| @@ -121,7 +121,7 @@ SharedPtr<Process> Process::Create(Core::System& system, std::string name, Proce | |||
| 121 | return process; | 121 | return process; |
| 122 | } | 122 | } |
| 123 | 123 | ||
| 124 | SharedPtr<ResourceLimit> Process::GetResourceLimit() const { | 124 | std::shared_ptr<ResourceLimit> Process::GetResourceLimit() const { |
| 125 | return resource_limit; | 125 | return resource_limit; |
| 126 | } | 126 | } |
| 127 | 127 | ||
| @@ -142,12 +142,12 @@ u64 Process::GetTotalPhysicalMemoryUsedWithoutSystemResource() const { | |||
| 142 | return GetTotalPhysicalMemoryUsed() - GetSystemResourceUsage(); | 142 | return GetTotalPhysicalMemoryUsed() - GetSystemResourceUsage(); |
| 143 | } | 143 | } |
| 144 | 144 | ||
| 145 | void Process::InsertConditionVariableThread(SharedPtr<Thread> thread) { | 145 | void Process::InsertConditionVariableThread(std::shared_ptr<Thread> thread) { |
| 146 | VAddr cond_var_addr = thread->GetCondVarWaitAddress(); | 146 | VAddr cond_var_addr = thread->GetCondVarWaitAddress(); |
| 147 | std::list<SharedPtr<Thread>>& thread_list = cond_var_threads[cond_var_addr]; | 147 | std::list<std::shared_ptr<Thread>>& thread_list = cond_var_threads[cond_var_addr]; |
| 148 | auto it = thread_list.begin(); | 148 | auto it = thread_list.begin(); |
| 149 | while (it != thread_list.end()) { | 149 | while (it != thread_list.end()) { |
| 150 | const SharedPtr<Thread> current_thread = *it; | 150 | const std::shared_ptr<Thread> current_thread = *it; |
| 151 | if (current_thread->GetPriority() > thread->GetPriority()) { | 151 | if (current_thread->GetPriority() > thread->GetPriority()) { |
| 152 | thread_list.insert(it, thread); | 152 | thread_list.insert(it, thread); |
| 153 | return; | 153 | return; |
| @@ -157,12 +157,12 @@ void Process::InsertConditionVariableThread(SharedPtr<Thread> thread) { | |||
| 157 | thread_list.push_back(thread); | 157 | thread_list.push_back(thread); |
| 158 | } | 158 | } |
| 159 | 159 | ||
| 160 | void Process::RemoveConditionVariableThread(SharedPtr<Thread> thread) { | 160 | void Process::RemoveConditionVariableThread(std::shared_ptr<Thread> thread) { |
| 161 | VAddr cond_var_addr = thread->GetCondVarWaitAddress(); | 161 | VAddr cond_var_addr = thread->GetCondVarWaitAddress(); |
| 162 | std::list<SharedPtr<Thread>>& thread_list = cond_var_threads[cond_var_addr]; | 162 | std::list<std::shared_ptr<Thread>>& thread_list = cond_var_threads[cond_var_addr]; |
| 163 | auto it = thread_list.begin(); | 163 | auto it = thread_list.begin(); |
| 164 | while (it != thread_list.end()) { | 164 | while (it != thread_list.end()) { |
| 165 | const SharedPtr<Thread> current_thread = *it; | 165 | const std::shared_ptr<Thread> current_thread = *it; |
| 166 | if (current_thread.get() == thread.get()) { | 166 | if (current_thread.get() == thread.get()) { |
| 167 | thread_list.erase(it); | 167 | thread_list.erase(it); |
| 168 | return; | 168 | return; |
| @@ -172,12 +172,13 @@ void Process::RemoveConditionVariableThread(SharedPtr<Thread> thread) { | |||
| 172 | UNREACHABLE(); | 172 | UNREACHABLE(); |
| 173 | } | 173 | } |
| 174 | 174 | ||
| 175 | std::vector<SharedPtr<Thread>> Process::GetConditionVariableThreads(const VAddr cond_var_addr) { | 175 | std::vector<std::shared_ptr<Thread>> Process::GetConditionVariableThreads( |
| 176 | std::vector<SharedPtr<Thread>> result{}; | 176 | const VAddr cond_var_addr) { |
| 177 | std::list<SharedPtr<Thread>>& thread_list = cond_var_threads[cond_var_addr]; | 177 | std::vector<std::shared_ptr<Thread>> result{}; |
| 178 | std::list<std::shared_ptr<Thread>>& thread_list = cond_var_threads[cond_var_addr]; | ||
| 178 | auto it = thread_list.begin(); | 179 | auto it = thread_list.begin(); |
| 179 | while (it != thread_list.end()) { | 180 | while (it != thread_list.end()) { |
| 180 | SharedPtr<Thread> current_thread = *it; | 181 | std::shared_ptr<Thread> current_thread = *it; |
| 181 | result.push_back(current_thread); | 182 | result.push_back(current_thread); |
| 182 | ++it; | 183 | ++it; |
| 183 | } | 184 | } |
| @@ -239,12 +240,12 @@ void Process::Run(s32 main_thread_priority, u64 stack_size) { | |||
| 239 | void Process::PrepareForTermination() { | 240 | void Process::PrepareForTermination() { |
| 240 | ChangeStatus(ProcessStatus::Exiting); | 241 | ChangeStatus(ProcessStatus::Exiting); |
| 241 | 242 | ||
| 242 | const auto stop_threads = [this](const std::vector<SharedPtr<Thread>>& thread_list) { | 243 | const auto stop_threads = [this](const std::vector<std::shared_ptr<Thread>>& thread_list) { |
| 243 | for (auto& thread : thread_list) { | 244 | for (auto& thread : thread_list) { |
| 244 | if (thread->GetOwnerProcess() != this) | 245 | if (thread->GetOwnerProcess() != this) |
| 245 | continue; | 246 | continue; |
| 246 | 247 | ||
| 247 | if (thread == system.CurrentScheduler().GetCurrentThread()) | 248 | if (thread.get() == system.CurrentScheduler().GetCurrentThread()) |
| 248 | continue; | 249 | continue; |
| 249 | 250 | ||
| 250 | // TODO(Subv): When are the other running/ready threads terminated? | 251 | // TODO(Subv): When are the other running/ready threads terminated? |