From: Robert LeBlanc Date: Thu, 17 Dec 2015 23:19:30 +0000 (+0000) Subject: common/PrioritizedQueue.h: Style clean up and remove uneeded includes. X-Git-Tag: v10.0.4~71^2~4 X-Git-Url: http://git-server-git.apps.pok.os.sepia.ceph.com/?a=commitdiff_plain;h=d790a60d8f7bd7bde5d8ed777894b06935a40aa2;p=ceph.git common/PrioritizedQueue.h: Style clean up and remove uneeded includes. Signed-Off-By: Robert LeBlanc --- diff --git a/src/common/PrioritizedQueue.h b/src/common/PrioritizedQueue.h index 5ae94a5fbc28..010f919ce006 100644 --- a/src/common/PrioritizedQueue.h +++ b/src/common/PrioritizedQueue.h @@ -15,13 +15,10 @@ #ifndef PRIORITY_QUEUE_H #define PRIORITY_QUEUE_H -#include "common/Mutex.h" #include "common/Formatter.h" #include -#include #include -#include /** * Manages queue for normal and strict priority items @@ -106,14 +103,16 @@ class PrioritizedQueue { } void put_tokens(unsigned t) { tokens += t; - if (tokens > max_tokens) + if (tokens > max_tokens) { tokens = max_tokens; + } } void take_tokens(unsigned t) { - if (tokens > t) + if (tokens > t) { tokens -= t; - else + } else { tokens = 0; + } } void enqueue(K cl, unsigned cost, T item) { q[cl].push_back(std::make_pair(cost, item)); @@ -136,12 +135,14 @@ class PrioritizedQueue { assert(!(q.empty())); assert(cur != q.end()); cur->second.pop_front(); - if (cur->second.empty()) + if (cur->second.empty()) { q.erase(cur++); - else + } else { ++cur; - if (cur == q.end()) + } + if (cur == q.end()) { cur = q.begin(); + } size--; } unsigned length() const { @@ -158,8 +159,9 @@ class PrioritizedQueue { ) { size -= filter_list_pairs(&(i->second), f, out); if (i->second.empty()) { - if (cur == i) + if (cur == i) { ++cur; + } q.erase(i++); } else { ++i; @@ -170,11 +172,13 @@ class PrioritizedQueue { } void remove_by_class(K k, std::list *out) { typename Classes::iterator i = q.find(k); - if (i == q.end()) + if (i == q.end()) { return; + } size -= i->second.size(); - if (i == cur) + if (i == cur) { ++cur; + } if (out) { for (typename ListPairs::reverse_iterator j = i->second.rbegin(); @@ -184,8 +188,9 @@ class PrioritizedQueue { } } q.erase(i); - if (cur == q.end()) + if (cur == q.end()) { cur = q.begin(); + } } void dump(Formatter *f) const { @@ -193,8 +198,9 @@ class PrioritizedQueue { f->dump_int("max_tokens", max_tokens); f->dump_int("size", size); f->dump_int("num_keys", q.size()); - if (!empty()) + if (!empty()) { f->dump_int("first_item_cost", front().first); + } } }; @@ -204,8 +210,9 @@ class PrioritizedQueue { SubQueue *create_queue(unsigned priority) { typename SubQueues::iterator p = queue.find(priority); - if (p != queue.end()) + if (p != queue.end()) { return &p->second; + } total_priority += priority; SubQueue *sq = &queue[priority]; sq->set_max_tokens(max_tokens_per_subqueue); @@ -220,8 +227,9 @@ class PrioritizedQueue { } void distribute_tokens(unsigned cost) { - if (total_priority == 0) + if (total_priority == 0) { return; + } for (typename SubQueues::iterator i = queue.begin(); i != queue.end(); ++i) { @@ -341,8 +349,9 @@ public: if (!(high_queue.empty())) { T ret = high_queue.rbegin()->second.front().second; high_queue.rbegin()->second.pop_front(); - if (high_queue.rbegin()->second.empty()) + if (high_queue.rbegin()->second.empty()) { high_queue.erase(high_queue.rbegin()->first); + } return ret; } @@ -358,8 +367,9 @@ public: unsigned cost = i->second.front().first; i->second.take_tokens(cost); i->second.pop_front(); - if (i->second.empty()) + if (i->second.empty()) { remove_queue(i->first); + } distribute_tokens(cost); return ret; } @@ -370,8 +380,9 @@ public: T ret = queue.rbegin()->second.front().second; unsigned cost = queue.rbegin()->second.front().first; queue.rbegin()->second.pop_front(); - if (queue.rbegin()->second.empty()) + if (queue.rbegin()->second.empty()) { remove_queue(queue.rbegin()->first); + } distribute_tokens(cost); return ret; }