public interface RateLimiter
Modifier and Type | Interface and Description |
---|---|
static class |
RateLimiter.Type |
Modifier and Type | Method and Description |
---|---|
<T> T |
attemptCall(java.util.function.Supplier<T> call)
Executes the call only if calls are available
|
long |
millisUntilNextCall() |
int |
numCallsLeft() |
<T> T |
waitForCall(java.util.function.Supplier<T> call)
Executes the call, waiting for more calls if necessary
|
<T> T attemptCall(java.util.function.Supplier<T> call)
T
- the resulting value of the callcall
- the call to executelong millisUntilNextCall()
int numCallsLeft()
<T> T waitForCall(java.util.function.Supplier<T> call) throws java.lang.InterruptedException
T
- the resulting value of the callcall
- the call to executejava.lang.InterruptedException
- if the waiting is interrupted