Fixes and corrections on formatting.

This commit is contained in:
Fernando Sahmkow 2019-03-19 22:20:15 -04:00 committed by FernandoS27
parent f35e09fe0d
commit db42bcb306
5 changed files with 30 additions and 41 deletions

View file

@ -45,10 +45,10 @@ Thread* Scheduler::PopNextReadyThread() {
Thread* next = nullptr;
Thread* thread = GetCurrentThread();
if (thread && thread->GetStatus() == ThreadStatus::Running) {
if (ready_queue.empty())
if (ready_queue.empty()) {
return thread;
}
// We have to do better than the current thread.
// This call returns null when that's not possible.
next = ready_queue.front();
@ -56,8 +56,9 @@ Thread* Scheduler::PopNextReadyThread() {
next = thread;
}
} else {
if (ready_queue.empty())
if (ready_queue.empty()) {
return nullptr;
}
next = ready_queue.front();
}
@ -176,8 +177,9 @@ void Scheduler::UnscheduleThread(Thread* thread, u32 priority) {
void Scheduler::SetThreadPriority(Thread* thread, u32 priority) {
std::lock_guard<std::mutex> lock(scheduler_mutex);
if (thread->GetPriority() == priority)
if (thread->GetPriority() == priority) {
return;
}
// If thread was ready, adjust queues
if (thread->GetStatus() == ThreadStatus::Ready)
@ -188,9 +190,10 @@ Thread* Scheduler::GetNextSuggestedThread(u32 core, u32 maximum_priority) const
std::lock_guard<std::mutex> lock(scheduler_mutex);
const u32 mask = 1U << core;
for (auto& thread : ready_queue) {
if ((thread->GetAffinityMask() & mask) != 0 && thread->GetPriority() < maximum_priority)
for (auto* thread : ready_queue) {
if ((thread->GetAffinityMask() & mask) != 0 && thread->GetPriority() < maximum_priority) {
return thread;
}
}
return nullptr;
}