From 55c73e10a72651c768285caf914b23a1ed486f04 Mon Sep 17 00:00:00 2001 From: Lioncash Date: Sun, 12 Aug 2018 12:47:11 -0400 Subject: [PATCH 1/3] thread_queue_list: Convert typedef to a type alias --- src/common/thread_queue_list.h | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/common/thread_queue_list.h b/src/common/thread_queue_list.h index 38a450d693..258c5f17aa 100644 --- a/src/common/thread_queue_list.h +++ b/src/common/thread_queue_list.h @@ -16,7 +16,7 @@ struct ThreadQueueList { // (dynamically resizable) circular buffers to remove their overhead when // inserting and popping. - typedef unsigned int Priority; + using Priority = unsigned int; // Number of priority levels. (Valid levels are [0..NUM_QUEUES).) static const Priority NUM_QUEUES = N; From 11470f331a8ff51f5e927fa269fd381b2d4262cb Mon Sep 17 00:00:00 2001 From: Lioncash Date: Sun, 12 Aug 2018 12:52:25 -0400 Subject: [PATCH 2/3] thread_queue_list: Make contains() and get_first() const member functions These don't directly modify the contained data. --- src/common/thread_queue_list.h | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/src/common/thread_queue_list.h b/src/common/thread_queue_list.h index 258c5f17aa..133122c5f4 100644 --- a/src/common/thread_queue_list.h +++ b/src/common/thread_queue_list.h @@ -26,9 +26,9 @@ struct ThreadQueueList { } // Only for debugging, returns priority level. - Priority contains(const T& uid) { + Priority contains(const T& uid) const { for (Priority i = 0; i < NUM_QUEUES; ++i) { - Queue& cur = queues[i]; + const Queue& cur = queues[i]; if (std::find(cur.data.cbegin(), cur.data.cend(), uid) != cur.data.cend()) { return i; } @@ -37,8 +37,8 @@ struct ThreadQueueList { return -1; } - T get_first() { - Queue* cur = first; + T get_first() const { + const Queue* cur = first; while (cur != nullptr) { if (!cur->data.empty()) { return cur->data.front(); From e850ff63bc51eb8ca2ec7b15167315ee648a4f73 Mon Sep 17 00:00:00 2001 From: Lioncash Date: Sun, 12 Aug 2018 12:55:56 -0400 Subject: [PATCH 3/3] scheduler: Make HaveReadyThreads() a const member function This function doesn't modify instance state, so the const qualifier can be added to it. --- src/core/hle/kernel/scheduler.cpp | 2 +- src/core/hle/kernel/scheduler.h | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/src/core/hle/kernel/scheduler.cpp b/src/core/hle/kernel/scheduler.cpp index 94065c736f..e770b91031 100644 --- a/src/core/hle/kernel/scheduler.cpp +++ b/src/core/hle/kernel/scheduler.cpp @@ -25,7 +25,7 @@ Scheduler::~Scheduler() { } } -bool Scheduler::HaveReadyThreads() { +bool Scheduler::HaveReadyThreads() const { std::lock_guard lock(scheduler_mutex); return ready_queue.get_first() != nullptr; } diff --git a/src/core/hle/kernel/scheduler.h b/src/core/hle/kernel/scheduler.h index 1a4ee8f36b..6a61ef64ea 100644 --- a/src/core/hle/kernel/scheduler.h +++ b/src/core/hle/kernel/scheduler.h @@ -21,7 +21,7 @@ public: ~Scheduler(); /// Returns whether there are any threads that are ready to run. - bool HaveReadyThreads(); + bool HaveReadyThreads() const; /// Reschedules to the next available thread (call after current thread is suspended) void Reschedule();