From: Mykola Golub Date: Thu, 14 Mar 2019 18:30:31 +0000 (+0000) Subject: common: allow "0" cost items to be queued by TokenBucketThrottle X-Git-Tag: v15.0.0~205^2~3 X-Git-Url: http://git.apps.os.sepia.ceph.com/?a=commitdiff_plain;h=4f7780a92c482562974923360e6b2d11bd8ffa58;p=ceph-ci.git common: allow "0" cost items to be queued by TokenBucketThrottle They will be queued if there are already blockers. Signed-off-by: Mykola Golub --- diff --git a/src/common/Throttle.h b/src/common/Throttle.h index f382140e8bf..1a6acac59d3 100644 --- a/src/common/Throttle.h +++ b/src/common/Throttle.h @@ -410,7 +410,7 @@ public: TokenBucketThrottle(CephContext *cct, const std::string &name, uint64_t capacity, uint64_t avg, SafeTimer *timer, Mutex *timer_lock); - + ~TokenBucketThrottle(); const std::string &get_name() { @@ -424,12 +424,9 @@ public: }); m_blockers.emplace_back(c, ctx); } - + template bool get(uint64_t c, T *handler, I *item, uint64_t flag) { - if (0 == c) - return false; - bool wait = false; uint64_t got = 0; std::lock_guard lock(m_lock); @@ -439,7 +436,7 @@ public: } else { if (0 == m_throttle.max || 0 == m_avg) return false; - + got = m_throttle.get(c); if (got < c) { // Not enough tokens, add a blocker for it. @@ -452,7 +449,7 @@ public: return wait; } - + int set_limit(uint64_t average, uint64_t burst); void set_schedule_tick_min(uint64_t tick);