summaryrefslogtreecommitdiff
path: root/src/common/thread_queue_list.h
diff options
context:
space:
mode:
authorbunnei <bunneidev@gmail.com>2018-12-15 00:28:12 -0500
committerGitHub <noreply@github.com>2018-12-15 00:28:12 -0500
commit2f2fc47af23708f4a79c1e3b554aafd84a32f7db (patch)
tree02114974dac4e65b2a1a011c7cad68b32a6a6a47 /src/common/thread_queue_list.h
parentb88430c29908a0f0b9cdbce139fac4f9c392eec6 (diff)
parente6f7825a248dd0ff9f2e3fdccabdbe3631622861 (diff)
Merge pull request #1732 from DarkLordZach/yield-types
svc: Implement yield types 0 and -1
Diffstat (limited to 'src/common/thread_queue_list.h')
-rw-r--r--src/common/thread_queue_list.h16
1 files changed, 16 insertions, 0 deletions
diff --git a/src/common/thread_queue_list.h b/src/common/thread_queue_list.h
index 133122c5f..e7594db68 100644
--- a/src/common/thread_queue_list.h
+++ b/src/common/thread_queue_list.h
@@ -49,6 +49,22 @@ struct ThreadQueueList {
return T();
}
+ template <typename UnaryPredicate>
+ T get_first_filter(UnaryPredicate filter) const {
+ const Queue* cur = first;
+ while (cur != nullptr) {
+ if (!cur->data.empty()) {
+ for (const auto& item : cur->data) {
+ if (filter(item))
+ return item;
+ }
+ }
+ cur = cur->next_nonempty;
+ }
+
+ return T();
+ }
+
T pop_first() {
Queue* cur = first;
while (cur != nullptr) {