diff options
Diffstat (limited to 'src')
| -rw-r--r-- | src/core/hle/kernel/address_arbiter.cpp | 36 |
1 files changed, 17 insertions, 19 deletions
diff --git a/src/core/hle/kernel/address_arbiter.cpp b/src/core/hle/kernel/address_arbiter.cpp index a1287de93..8475b698c 100644 --- a/src/core/hle/kernel/address_arbiter.cpp +++ b/src/core/hle/kernel/address_arbiter.cpp | |||
| @@ -201,31 +201,29 @@ void AddressArbiter::HandleWakeupThread(std::shared_ptr<Thread> thread) { | |||
| 201 | void AddressArbiter::InsertThread(std::shared_ptr<Thread> thread) { | 201 | void AddressArbiter::InsertThread(std::shared_ptr<Thread> thread) { |
| 202 | const VAddr arb_addr = thread->GetArbiterWaitAddress(); | 202 | const VAddr arb_addr = thread->GetArbiterWaitAddress(); |
| 203 | std::list<std::shared_ptr<Thread>>& thread_list = arb_threads[arb_addr]; | 203 | std::list<std::shared_ptr<Thread>>& thread_list = arb_threads[arb_addr]; |
| 204 | auto it = thread_list.begin(); | 204 | |
| 205 | while (it != thread_list.end()) { | 205 | const auto iter = |
| 206 | const std::shared_ptr<Thread>& current_thread = *it; | 206 | std::find_if(thread_list.cbegin(), thread_list.cend(), [&thread](const auto& entry) { |
| 207 | if (current_thread->GetPriority() >= thread->GetPriority()) { | 207 | return entry->GetPriority() >= thread->GetPriority(); |
| 208 | thread_list.insert(it, thread); | 208 | }); |
| 209 | return; | 209 | |
| 210 | } | 210 | if (iter == thread_list.cend()) { |
| 211 | ++it; | 211 | thread_list.push_back(std::move(thread)); |
| 212 | } else { | ||
| 213 | thread_list.insert(iter, std::move(thread)); | ||
| 212 | } | 214 | } |
| 213 | thread_list.push_back(std::move(thread)); | ||
| 214 | } | 215 | } |
| 215 | 216 | ||
| 216 | void AddressArbiter::RemoveThread(std::shared_ptr<Thread> thread) { | 217 | void AddressArbiter::RemoveThread(std::shared_ptr<Thread> thread) { |
| 217 | const VAddr arb_addr = thread->GetArbiterWaitAddress(); | 218 | const VAddr arb_addr = thread->GetArbiterWaitAddress(); |
| 218 | std::list<std::shared_ptr<Thread>>& thread_list = arb_threads[arb_addr]; | 219 | std::list<std::shared_ptr<Thread>>& thread_list = arb_threads[arb_addr]; |
| 219 | auto it = thread_list.begin(); | 220 | |
| 220 | while (it != thread_list.end()) { | 221 | const auto iter = std::find_if(thread_list.cbegin(), thread_list.cend(), |
| 221 | const std::shared_ptr<Thread>& current_thread = *it; | 222 | [&thread](const auto& entry) { return thread == entry; }); |
| 222 | if (current_thread.get() == thread.get()) { | 223 | |
| 223 | thread_list.erase(it); | 224 | ASSERT(iter != thread_list.cend()); |
| 224 | return; | 225 | |
| 225 | } | 226 | thread_list.erase(iter); |
| 226 | ++it; | ||
| 227 | } | ||
| 228 | UNREACHABLE(); | ||
| 229 | } | 227 | } |
| 230 | 228 | ||
| 231 | std::vector<std::shared_ptr<Thread>> AddressArbiter::GetThreadsWaitingOnAddress( | 229 | std::vector<std::shared_ptr<Thread>> AddressArbiter::GetThreadsWaitingOnAddress( |