mirror of
https://github.com/yuzu-mirror/yuzu.git
synced 2024-11-09 16:19:59 +00:00
Merge pull request #1036 from lioncash/thread
scheduler: Make HaveReadyThreads() a const member function
This commit is contained in:
commit
9608f51cde
3 changed files with 7 additions and 7 deletions
|
@ -16,7 +16,7 @@ struct ThreadQueueList {
|
||||||
// (dynamically resizable) circular buffers to remove their overhead when
|
// (dynamically resizable) circular buffers to remove their overhead when
|
||||||
// inserting and popping.
|
// inserting and popping.
|
||||||
|
|
||||||
typedef unsigned int Priority;
|
using Priority = unsigned int;
|
||||||
|
|
||||||
// Number of priority levels. (Valid levels are [0..NUM_QUEUES).)
|
// Number of priority levels. (Valid levels are [0..NUM_QUEUES).)
|
||||||
static const Priority NUM_QUEUES = N;
|
static const Priority NUM_QUEUES = N;
|
||||||
|
@ -26,9 +26,9 @@ struct ThreadQueueList {
|
||||||
}
|
}
|
||||||
|
|
||||||
// Only for debugging, returns priority level.
|
// 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) {
|
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()) {
|
if (std::find(cur.data.cbegin(), cur.data.cend(), uid) != cur.data.cend()) {
|
||||||
return i;
|
return i;
|
||||||
}
|
}
|
||||||
|
@ -37,8 +37,8 @@ struct ThreadQueueList {
|
||||||
return -1;
|
return -1;
|
||||||
}
|
}
|
||||||
|
|
||||||
T get_first() {
|
T get_first() const {
|
||||||
Queue* cur = first;
|
const Queue* cur = first;
|
||||||
while (cur != nullptr) {
|
while (cur != nullptr) {
|
||||||
if (!cur->data.empty()) {
|
if (!cur->data.empty()) {
|
||||||
return cur->data.front();
|
return cur->data.front();
|
||||||
|
|
|
@ -25,7 +25,7 @@ Scheduler::~Scheduler() {
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
bool Scheduler::HaveReadyThreads() {
|
bool Scheduler::HaveReadyThreads() const {
|
||||||
std::lock_guard<std::mutex> lock(scheduler_mutex);
|
std::lock_guard<std::mutex> lock(scheduler_mutex);
|
||||||
return ready_queue.get_first() != nullptr;
|
return ready_queue.get_first() != nullptr;
|
||||||
}
|
}
|
||||||
|
|
|
@ -21,7 +21,7 @@ public:
|
||||||
~Scheduler();
|
~Scheduler();
|
||||||
|
|
||||||
/// Returns whether there are any threads that are ready to run.
|
/// 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)
|
/// Reschedules to the next available thread (call after current thread is suspended)
|
||||||
void Reschedule();
|
void Reschedule();
|
||||||
|
|
Loading…
Reference in a new issue