diff options
| author | 2015-04-09 23:05:49 -0400 | |
|---|---|---|
| committer | 2015-04-09 23:05:49 -0400 | |
| commit | 6f1143885bcc02642b707b51355fe4b6cd5375c7 (patch) | |
| tree | fe1307919e7087df41c498b971016ffa931d6594 /src/common/thread_queue_list.h | |
| parent | Merge pull request #690 from Zaneo/sharedmemory (diff) | |
| parent | SVC: Assert on unsupported CreateThread processor ID. (diff) | |
| download | yuzu-6f1143885bcc02642b707b51355fe4b6cd5375c7.tar.gz yuzu-6f1143885bcc02642b707b51355fe4b6cd5375c7.tar.xz yuzu-6f1143885bcc02642b707b51355fe4b6cd5375c7.zip | |
Merge pull request #683 from bunnei/thread-priority
Thread priority and scheduler improvements
Diffstat (limited to 'src/common/thread_queue_list.h')
| -rw-r--r-- | src/common/thread_queue_list.h | 18 |
1 files changed, 18 insertions, 0 deletions
diff --git a/src/common/thread_queue_list.h b/src/common/thread_queue_list.h index 444abf115..4f27fc899 100644 --- a/src/common/thread_queue_list.h +++ b/src/common/thread_queue_list.h | |||
| @@ -40,6 +40,18 @@ struct ThreadQueueList { | |||
| 40 | return -1; | 40 | return -1; |
| 41 | } | 41 | } |
| 42 | 42 | ||
| 43 | T get_first() { | ||
| 44 | Queue *cur = first; | ||
| 45 | while (cur != nullptr) { | ||
| 46 | if (!cur->data.empty()) { | ||
| 47 | return cur->data.front(); | ||
| 48 | } | ||
| 49 | cur = cur->next_nonempty; | ||
| 50 | } | ||
| 51 | |||
| 52 | return T(); | ||
| 53 | } | ||
| 54 | |||
| 43 | T pop_first() { | 55 | T pop_first() { |
| 44 | Queue *cur = first; | 56 | Queue *cur = first; |
| 45 | while (cur != nullptr) { | 57 | while (cur != nullptr) { |
| @@ -79,6 +91,12 @@ struct ThreadQueueList { | |||
| 79 | cur->data.push_back(thread_id); | 91 | cur->data.push_back(thread_id); |
| 80 | } | 92 | } |
| 81 | 93 | ||
| 94 | void move(const T& thread_id, Priority old_priority, Priority new_priority) { | ||
| 95 | remove(old_priority, thread_id); | ||
| 96 | prepare(new_priority); | ||
| 97 | push_back(new_priority, thread_id); | ||
| 98 | } | ||
| 99 | |||
| 82 | void remove(Priority priority, const T& thread_id) { | 100 | void remove(Priority priority, const T& thread_id) { |
| 83 | Queue *cur = &queues[priority]; | 101 | Queue *cur = &queues[priority]; |
| 84 | boost::remove_erase(cur->data, thread_id); | 102 | boost::remove_erase(cur->data, thread_id); |