MCPcopy Create free account
hub / github.com/ceph/ceph / Klass

Class Klass

src/common/WeightedPriorityQueue.h:65–119  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

63 {}
64 };
65 class Klass : public bi::set_base_hook<>
66 {
67 typedef bi::list<ListPair> ListPairs;
68 typedef typename ListPairs::iterator Lit;
69 public:
70 K key; // klass
71 ListPairs lp;
72 Klass(K& k) :
73 key(k) {
74 }
75 ~Klass() {
76 lp.clear_and_dispose(DelItem<ListPair>());
77 }
78 friend bool operator< (const Klass &a, const Klass &b)
79 { return a.key < b.key; }
80 friend bool operator> (const Klass &a, const Klass &b)
81 { return a.key > b.key; }
82 friend bool operator== (const Klass &a, const Klass &b)
83 { return a.key == b.key; }
84 void insert(unsigned cost, T&& item, bool front) {
85 if (front) {
86 lp.push_front(*new ListPair(cost, std::move(item)));
87 } else {
88 lp.push_back(*new ListPair(cost, std::move(item)));
89 }
90 }
91 //Get the cost of the next item to dequeue
92 unsigned get_cost() const {
93 ceph_assert(!empty());
94 return lp.begin()->cost;
95 }
96 T pop() {
97 ceph_assert(!lp.empty());
98 T ret = std::move(lp.begin()->item);
99 lp.erase_and_dispose(lp.begin(), DelItem<ListPair>());
100 return ret;
101 }
102 bool empty() const {
103 return lp.empty();
104 }
105 unsigned get_size() const {
106 return lp.size();
107 }
108 void filter_class(std::list<T>* out) {
109 for (Lit i = --lp.end();; --i) {
110 if (out) {
111 out->push_front(std::move(i->item));
112 }
113 i = lp.erase_and_dispose(i, DelItem<ListPair>());
114 if (i == lp.begin()) {
115 break;
116 }
117 }
118 }
119 };
120 class SubQueue : public bi::set_base_hook<>
121 {
122 typedef bi::rbtree<Klass> Klasses;

Callers 3

TEST_FFunction · 0.85
fill_queueMethod · 0.85
TEST_FFunction · 0.85

Calls

no outgoing calls

Tested by 3

TEST_FFunction · 0.68
fill_queueMethod · 0.68
TEST_FFunction · 0.68