acquire method
Wait until a token is available, then consume it.
Implementation
@override
Future<void> acquire() async {
while (true) {
_refill();
if (_tokens >= 1) {
_tokens -= 1;
return;
}
final need = 1 - _tokens;
final waitMs = math.max(10, (need / refillPerSecond * 1000).ceil());
await Future<void>.delayed(Duration(milliseconds: waitMs));
}
}