From: Haomai Wang Date: Wed, 23 Dec 2015 06:41:59 +0000 (+0800) Subject: Throttler: Add reset support X-Git-Tag: v11.1.0~368^2~13 X-Git-Url: http://git-server-git.apps.pok.os.sepia.ceph.com/?a=commitdiff_plain;h=c97f2ceb3c9f59713b05e4f5cd4a2ad8e731e57c;p=ceph.git Throttler: Add reset support Signed-off-by: Haomai Wang --- diff --git a/src/common/Throttle.cc b/src/common/Throttle.cc index 69d98da418c..7ba623252e2 100644 --- a/src/common/Throttle.cc +++ b/src/common/Throttle.cc @@ -235,6 +235,17 @@ int64_t Throttle::put(int64_t c) return count.read(); } +void Throttle::reset() +{ + Mutex::Locker l(lock); + if (!cond.empty()) + cond.front()->SignalOne(); + count.set(0); + if (logger) { + logger->set(l_throttle_val, 0); + } +} + bool BackoffThrottle::set_params( double _low_threshhold, double _high_threshhold, diff --git a/src/common/Throttle.h b/src/common/Throttle.h index cafe0d9a116..b920d195de6 100644 --- a/src/common/Throttle.h +++ b/src/common/Throttle.h @@ -105,6 +105,11 @@ public: * @returns number of requests being hold after this */ int64_t put(int64_t c = 1); + /** + * reset the zero to the stock + */ + void reset(); + bool should_wait(int64_t c) const { return _should_wait(c); }