| 116 | RateLimiterProcess& operator=(const RateLimiterProcess&); |
| 117 | |
| 118 | void _acquire() |
| 119 | { |
| 120 | CHECK(!promises.empty()); |
| 121 | |
| 122 | // Keep removing the top of the queue until we find a promise |
| 123 | // whose future is not discarded. |
| 124 | while (!promises.empty()) { |
| 125 | Promise<Nothing>* promise = promises.front(); |
| 126 | promises.pop_front(); |
| 127 | if (!promise->future().isDiscarded()) { |
| 128 | promise->set(Nothing()); |
| 129 | delete promise; |
| 130 | timeout = Seconds(1) / permitsPerSecond; |
| 131 | break; |
| 132 | } else { |
| 133 | delete promise; |
| 134 | } |
| 135 | } |
| 136 | |
| 137 | // Repeat if necessary. |
| 138 | if (!promises.empty()) { |
| 139 | delay(timeout.remaining(), self(), &Self::_acquire); |
| 140 | } |
| 141 | } |
| 142 | |
| 143 | void discard(const Future<Nothing>& future) |
| 144 | { |