MCPcopy Create free account
hub / github.com/3rdparty/libprocess / _acquire

Method _acquire

include/process/limiter.hpp:118–141  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

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 {

Callers

nothing calls this directly

Calls 6

isDiscardedMethod · 0.80
futureMethod · 0.80
delayFunction · 0.70
emptyMethod · 0.45
setMethod · 0.45
remainingMethod · 0.45

Tested by

no test coverage detected