Updates storedPermits and nextFreeTicketMicros based on the current time.
(long nowMicros)
| 383 | */ |
| 384 | |
| 385 | void resync(long nowMicros) { |
| 386 | // if nextFreeTicket is in the past, resync to now |
| 387 | if (nowMicros > nextFreeTicketMicros) { |
| 388 | double newPermits = (nowMicros - nextFreeTicketMicros) / coolDownIntervalMicros(); |
| 389 | storedPermits = min(maxPermits, storedPermits + newPermits); |
| 390 | nextFreeTicketMicros = nowMicros; |
| 391 | } |
| 392 | } |
| 393 | } |
no test coverage detected