aboutsummaryrefslogtreecommitdiff
path: root/src/core/hle/kernel/scheduler.cpp
diff options
context:
space:
mode:
authorLioncash <mathew1800@gmail.com>2018-07-19 21:39:05 -0400
committerLioncash <mathew1800@gmail.com>2018-07-19 22:08:56 -0400
commitdbfe82773d98fadac481cd9061f5eda98aebf308 (patch)
treeee1c5f480bcbf95339eff8677f061bbb57d8ee95 /src/core/hle/kernel/scheduler.cpp
parentd3cfaf95c883512691df01e90d8ab7e8873c2c3d (diff)
thread: Convert ThreadStatus into an enum class
Makes the thread status strongly typed, so implicit conversions can't happen. It also makes it easier to catch mistakes at compile time.
Diffstat (limited to 'src/core/hle/kernel/scheduler.cpp')
-rw-r--r--src/core/hle/kernel/scheduler.cpp16
1 files changed, 8 insertions, 8 deletions
diff --git a/src/core/hle/kernel/scheduler.cpp b/src/core/hle/kernel/scheduler.cpp
index 1f4abfbe8..f7e25cbf5 100644
--- a/src/core/hle/kernel/scheduler.cpp
+++ b/src/core/hle/kernel/scheduler.cpp
@@ -34,7 +34,7 @@ Thread* Scheduler::PopNextReadyThread() {
Thread* next = nullptr;
Thread* thread = GetCurrentThread();
- if (thread && thread->status == THREADSTATUS_RUNNING) {
+ if (thread && thread->status == ThreadStatus::Running) {
// We have to do better than the current thread.
// This call returns null when that's not possible.
next = ready_queue.pop_first_better(thread->current_priority);
@@ -57,17 +57,17 @@ void Scheduler::SwitchContext(Thread* new_thread) {
previous_thread->last_running_ticks = CoreTiming::GetTicks();
cpu_core->SaveContext(previous_thread->context);
- if (previous_thread->status == THREADSTATUS_RUNNING) {
+ if (previous_thread->status == ThreadStatus::Running) {
// This is only the case when a reschedule is triggered without the current thread
// yielding execution (i.e. an event triggered, system core time-sliced, etc)
ready_queue.push_front(previous_thread->current_priority, previous_thread);
- previous_thread->status = THREADSTATUS_READY;
+ previous_thread->status = ThreadStatus::Ready;
}
}
// Load context of new thread
if (new_thread) {
- ASSERT_MSG(new_thread->status == THREADSTATUS_READY,
+ ASSERT_MSG(new_thread->status == ThreadStatus::Ready,
"Thread must be ready to become running.");
// Cancel any outstanding wakeup events for this thread
@@ -78,7 +78,7 @@ void Scheduler::SwitchContext(Thread* new_thread) {
current_thread = new_thread;
ready_queue.remove(new_thread->current_priority, new_thread);
- new_thread->status = THREADSTATUS_RUNNING;
+ new_thread->status = ThreadStatus::Running;
if (previous_process != current_thread->owner_process) {
Core::CurrentProcess() = current_thread->owner_process;
@@ -129,14 +129,14 @@ void Scheduler::RemoveThread(Thread* thread) {
void Scheduler::ScheduleThread(Thread* thread, u32 priority) {
std::lock_guard<std::mutex> lock(scheduler_mutex);
- ASSERT(thread->status == THREADSTATUS_READY);
+ ASSERT(thread->status == ThreadStatus::Ready);
ready_queue.push_back(priority, thread);
}
void Scheduler::UnscheduleThread(Thread* thread, u32 priority) {
std::lock_guard<std::mutex> lock(scheduler_mutex);
- ASSERT(thread->status == THREADSTATUS_READY);
+ ASSERT(thread->status == ThreadStatus::Ready);
ready_queue.remove(priority, thread);
}
@@ -144,7 +144,7 @@ void Scheduler::SetThreadPriority(Thread* thread, u32 priority) {
std::lock_guard<std::mutex> lock(scheduler_mutex);
// If thread was ready, adjust queues
- if (thread->status == THREADSTATUS_READY)
+ if (thread->status == ThreadStatus::Ready)
ready_queue.move(thread, thread->current_priority, priority);
else
ready_queue.prepare(priority);