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)
{
*/
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
* 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();
}
* 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