From bc8d14db3fd872677705e22d9b15ccea34e339be Mon Sep 17 00:00:00 2001 From: Kefu Chai Date: Thu, 23 Apr 2015 15:50:50 +0800 Subject: [PATCH] Throttle: add more constness Signed-off-by: Kefu Chai --- src/common/Throttle.cc | 4 ++-- src/common/Throttle.h | 14 +++++++------- 2 files changed, 9 insertions(+), 9 deletions(-) diff --git a/src/common/Throttle.cc b/src/common/Throttle.cc index 18a8bb1975b6..ecef40744a6d 100644 --- a/src/common/Throttle.cc +++ b/src/common/Throttle.cc @@ -29,9 +29,9 @@ enum { l_throttle_last, }; -Throttle::Throttle(CephContext *cct, std::string n, int64_t m, bool _use_perf) +Throttle::Throttle(CephContext *cct, const std::string& n, int64_t m, bool _use_perf) : cct(cct), name(n), logger(NULL), - max(m), + max(m), lock("Throttle::lock"), use_perf(_use_perf) { diff --git a/src/common/Throttle.h b/src/common/Throttle.h index 2423c92b43bc..5c97486f1b3c 100644 --- a/src/common/Throttle.h +++ b/src/common/Throttle.h @@ -22,20 +22,20 @@ class PerfCounters; */ class Throttle { CephContext *cct; - std::string name; + const std::string name; PerfCounters *logger; ceph::atomic_t count, max; Mutex lock; list cond; - bool use_perf; - + const bool use_perf; + public: - Throttle(CephContext *cct, std::string n, int64_t m = 0, bool _use_perf = true); + Throttle(CephContext *cct, const std::string& n, int64_t m = 0, bool _use_perf = true); ~Throttle(); private: void _reset_max(int64_t m); - bool _should_wait(int64_t c) { + bool _should_wait(int64_t c) const { int64_t m = max.read(); int64_t cur = count.read(); return @@ -51,7 +51,7 @@ public: * gets the number of currently taken slots * @returns the number of taken slots */ - int64_t get_current() { + int64_t get_current() const { return count.read(); } @@ -59,7 +59,7 @@ public: * get the max number of slots * @returns the max number of slots */ - int64_t get_max() { return max.read(); } + int64_t get_max() const { return max.read(); } /** * set the new max number, and wait until the number of taken slots drains -- 2.47.3