summaryrefslogtreecommitdiff
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..323eab97c 100644
--- a/src/common/thread_queue_list.h
+++ b/src/common/thread_queue_list.h
@@ -6,6 +6,7 @@
6 6
7#include <array> 7#include <array>
8#include <deque> 8#include <deque>
9#include <functional>
9#include <boost/range/algorithm_ext/erase.hpp> 10#include <boost/range/algorithm_ext/erase.hpp>
10 11
11namespace Common { 12namespace Common {
@@ -49,6 +50,21 @@ struct ThreadQueueList {
49 return T(); 50 return T();
50 } 51 }
51 52
53 T get_first_filter(std::function<bool(T)> filter) const {
54 const Queue* cur = first;
55 while (cur != nullptr) {
56 if (!cur->data.empty()) {
57 for (const auto& item : cur->data) {
58 if (filter(item))
59 return item;
60 }
61 }
62 cur = cur->next_nonempty;
63 }
64
65 return T();
66 }
67
52 T pop_first() { 68 T pop_first() {
53 Queue* cur = first; 69 Queue* cur = first;
54 while (cur != nullptr) { 70 while (cur != nullptr) {