summaryrefslogtreecommitdiffstats
path: root/src/common/thread_queue_list.h
diff options
context:
space:
mode:
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) {