summaryrefslogtreecommitdiff
path: root/src/common
diff options
context:
space:
mode:
Diffstat (limited to 'src/common')
-rw-r--r--src/common/thread_queue_list.h18
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);