summaryrefslogtreecommitdiff
path: root/src/core/hle/kernel/kernel.cpp
diff options
context:
space:
mode:
Diffstat (limited to 'src/core/hle/kernel/kernel.cpp')
-rw-r--r--src/core/hle/kernel/kernel.cpp23
1 files changed, 15 insertions, 8 deletions
diff --git a/src/core/hle/kernel/kernel.cpp b/src/core/hle/kernel/kernel.cpp
index ef9dbafa5..6f61d526a 100644
--- a/src/core/hle/kernel/kernel.cpp
+++ b/src/core/hle/kernel/kernel.cpp
@@ -3,7 +3,6 @@
3// Refer to the license.txt file included. 3// Refer to the license.txt file included.
4 4
5#include <algorithm> 5#include <algorithm>
6#include <boost/range/algorithm_ext/erase.hpp>
7#include "common/assert.h" 6#include "common/assert.h"
8#include "common/logging/log.h" 7#include "common/logging/log.h"
9#include "core/hle/config_mem.h" 8#include "core/hle/config_mem.h"
@@ -34,10 +33,17 @@ void WaitObject::RemoveWaitingThread(Thread* thread) {
34 33
35SharedPtr<Thread> WaitObject::GetHighestPriorityReadyThread() { 34SharedPtr<Thread> WaitObject::GetHighestPriorityReadyThread() {
36 // Remove the threads that are ready or already running from our waitlist 35 // Remove the threads that are ready or already running from our waitlist
37 boost::range::remove_erase_if(waiting_threads, [](const SharedPtr<Thread>& thread) { 36 auto to_remove = waiting_threads.end();
38 return thread->status == THREADSTATUS_RUNNING || thread->status == THREADSTATUS_READY || 37 do {
39 thread->status == THREADSTATUS_DEAD; 38 to_remove = std::find_if(waiting_threads.begin(), waiting_threads.end(),
40 }); 39 [](const SharedPtr<Thread>& thread) {
40 return thread->status == THREADSTATUS_RUNNING ||
41 thread->status == THREADSTATUS_READY ||
42 thread->status == THREADSTATUS_DEAD;
43 });
44 // Call RemoveWaitingThread so that child classes can override the behavior.
45 RemoveWaitingThread(to_remove->get());
46 } while (to_remove != waiting_threads.end());
41 47
42 Thread* candidate = nullptr; 48 Thread* candidate = nullptr;
43 s32 candidate_priority = THREADPRIO_LOWEST + 1; 49 s32 candidate_priority = THREADPRIO_LOWEST + 1;
@@ -49,9 +55,10 @@ SharedPtr<Thread> WaitObject::GetHighestPriorityReadyThread() {
49 if (ShouldWait(thread.get())) 55 if (ShouldWait(thread.get()))
50 continue; 56 continue;
51 57
52 bool ready_to_run = 58 bool ready_to_run = std::none_of(thread->wait_objects.begin(), thread->wait_objects.end(),
53 std::none_of(thread->wait_objects.begin(), thread->wait_objects.end(), 59 [&thread](const SharedPtr<WaitObject>& object) {
54 [&thread](const SharedPtr<WaitObject>& object) { return object->ShouldWait(thread.get()); }); 60 return object->ShouldWait(thread.get());
61 });
55 if (ready_to_run) { 62 if (ready_to_run) {
56 candidate = thread.get(); 63 candidate = thread.get();
57 candidate_priority = thread->current_priority; 64 candidate_priority = thread->current_priority;