]> git.apps.os.sepia.ceph.com Git - ceph.git/commitdiff
Throttle: add more constness 4445/head
authorKefu Chai <kchai@redhat.com>
Thu, 23 Apr 2015 07:50:50 +0000 (15:50 +0800)
committerKefu Chai <kchai@redhat.com>
Thu, 23 Apr 2015 08:49:54 +0000 (16:49 +0800)
Signed-off-by: Kefu Chai <kchai@redhat.com>
src/common/Throttle.cc
src/common/Throttle.h

index 18a8bb1975b69a35dfaf0580db12f5537c6323c2..ecef40744a6d061e10057e3877b1e59548695024 100644 (file)
@@ -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)
 {
index 2423c92b43bcd2985fcafd273f79169763fa5d0e..5c97486f1b3c431bf6442dd01ff0f3299006d0f7 100644 (file)
@@ -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*> 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