public interface RecyclableRateLimiter
| Modifier and Type | Method and Description |
|---|---|
default double |
acquire()
Acquires a single permit, waiting until enough permits are available.
|
double |
acquire(int permits)
Acquires the requested number of permits, waiting until enough permits are available.
|
double |
getRate()
Returns the currently configured rate per second at which new permits become available.
|
boolean |
immediatelyAvailable(int permits)
Checks whether there's enough permits accumulated to cover the number of requested permits.
|
void |
recyclePermits(int permits)
Return the specified number of permits back to the pool.
|
void |
setRate(double rate)
Updates the rate for this
RateLimiter. |
default boolean |
tryAcquire()
Acquires a single permit only if can be acquired without wait.
|
boolean |
tryAcquire(int permits)
Acquires the requested number of permits only if can be acquired without wait.
|
double getRate()
void setRate(double rate)
RateLimiter.rate - new rate per second@CanIgnoreReturnValue double acquire(int permits)
permits - number of permits to request@CanIgnoreReturnValue default double acquire()
boolean tryAcquire(int permits)
permits - number of permits to requestdefault boolean tryAcquire()
void recyclePermits(int permits)
permits - number of permits to returnboolean immediatelyAvailable(int permits)
permits - permits to checkCopyright © 2020. All rights reserved.