diff options
author | Kefu Chai <tchaikov@gmail.com> | 2018-11-26 11:49:12 +0100 |
---|---|---|
committer | GitHub <noreply@github.com> | 2018-11-26 11:49:12 +0100 |
commit | b7def6f79738da01bec4300aca0ec92c6b8beebd (patch) | |
tree | fb1344e41f0acd37aad16250c1020ca7bdbcb939 /src/common/Throttle.h | |
parent | Merge pull request #23834 from DikshaGodbole/wip-feature-24571 (diff) | |
parent | common/Throttle: update BackoffThrottle::get() to work with unsigned delay (diff) | |
download | ceph-b7def6f79738da01bec4300aca0ec92c6b8beebd.tar.xz ceph-b7def6f79738da01bec4300aca0ec92c6b8beebd.zip |
Merge pull request #25105 from tchaikov/wip-ceph-mutex-common
common: Mutex -> ceph::mutex
Reviewed-by: Sage Weil <sage@redhat.com>
Reviewed-by: Adam Emerson <aemerson@redhat.com>
Reviewed-by: Josh Durgin <jdurgin@redhat.com>
Diffstat (limited to 'src/common/Throttle.h')
-rw-r--r-- | src/common/Throttle.h | 17 |
1 files changed, 8 insertions, 9 deletions
diff --git a/src/common/Throttle.h b/src/common/Throttle.h index a70b28c0c19..0164dc9815a 100644 --- a/src/common/Throttle.h +++ b/src/common/Throttle.h @@ -6,12 +6,11 @@ #include <atomic> #include <chrono> -#include <condition_variable> #include <iostream> #include <list> #include <map> -#include <mutex> +#include "common/ceph_mutex.h" #include "include/Context.h" #include "common/ThrottleInterface.h" #include "common/Timer.h" @@ -50,7 +49,7 @@ private: (c >= m && cur > m)); // except for large c } - bool _wait(int64_t c, UNIQUE_LOCK_T(lock)& l); + bool _wait(int64_t c, std::unique_lock<std::mutex>& l); public: /** @@ -122,7 +121,7 @@ public: return _should_wait(c); } void reset_max(int64_t m) { - auto l = ceph::uniquely_lock(lock); + std::lock_guard l(lock); _reset_max(m); } }; @@ -199,7 +198,7 @@ class BackoffThrottle { uint64_t max = 0; uint64_t current = 0; - std::chrono::duration<double> _get_delay(uint64_t c) const; + ceph::timespan _get_delay(uint64_t c) const; public: /** @@ -218,8 +217,8 @@ public: uint64_t throttle_max, ostream *errstream); - std::chrono::duration<double> get(uint64_t c = 1); - std::chrono::duration<double> wait() { + ceph::timespan get(uint64_t c = 1); + ceph::timespan wait() { return get(0); } uint64_t put(uint64_t c = 1); @@ -328,7 +327,7 @@ private: TidResult m_tid_result; - void complete_pending_ops(UNIQUE_LOCK_T(m_lock)& l); + void complete_pending_ops(std::unique_lock<std::mutex>& l); uint32_t waiters = 0; }; @@ -427,7 +426,7 @@ public: bool wait = false; uint64_t got = 0; - std::lock_guard<Mutex> lock(m_lock); + std::lock_guard lock(m_lock); if (!m_blockers.empty()) { // Keep the order of requests, add item after previous blocked requests. wait = true; |