| 152 | } |
| 153 | |
| 154 | bool Throttle::get(int64_t c, int64_t m) |
| 155 | { |
| 156 | if (0 == max && 0 == m) { |
| 157 | count += c; |
| 158 | return false; |
| 159 | } |
| 160 | |
| 161 | ceph_assert(c >= 0); |
| 162 | ldout(cct, 10) << "get " << c << " (" << count.load() << " -> " << (count.load() + c) << ")" << dendl; |
| 163 | if (logger) { |
| 164 | logger->inc(l_throttle_get_started); |
| 165 | } |
| 166 | bool waited = false; |
| 167 | { |
| 168 | std::unique_lock l(lock); |
| 169 | if (m) { |
| 170 | ceph_assert(m > 0); |
| 171 | _reset_max(m); |
| 172 | } |
| 173 | waited = _wait(c, l); |
| 174 | count += c; |
| 175 | } |
| 176 | if (logger) { |
| 177 | logger->inc(l_throttle_get); |
| 178 | logger->inc(l_throttle_get_sum, c); |
| 179 | logger->set(l_throttle_val, count); |
| 180 | } |
| 181 | return waited; |
| 182 | } |
| 183 | |
| 184 | /* Returns true if it successfully got the requested amount, |
| 185 | * or false if it would block. |
no test coverage detected