| 69 | } |
| 70 | |
| 71 | void Release(uint64_t values) { |
| 72 | if (Unthrottled()) { |
| 73 | return; |
| 74 | } |
| 75 | Future<> to_complete; |
| 76 | { |
| 77 | std::lock_guard<std::mutex> lg(mutex_); |
| 78 | current_value_ -= values; |
| 79 | if (in_waiting_ > 0 && current_value_ < max_value_) { |
| 80 | in_waiting_ = 0; |
| 81 | to_complete = backpressure_; |
| 82 | } |
| 83 | } |
| 84 | if (to_complete.is_valid()) { |
| 85 | to_complete.MarkFinished(); |
| 86 | } |
| 87 | } |
| 88 | |
| 89 | private: |
| 90 | Future<> backpressure_ = Future<>::MakeFinished(); |
no test coverage detected