public interface RateLimiter
getWaitTimeNanos(long)
.Modifier and Type | Method and Description |
---|---|
Optional<Long> |
acquire()
Acquire a permit for the next operation.
|
static RateLimiter |
createRateLimiter(long permitsPerSecond) |
long |
getWaitTimeNanos(long permit)
Checks how long is needed to wait for this permit to be ready.
|
Optional<Long> acquire()
Optional.empty()
if no waiting is needed, otherwise
the value contained in the returned optional is the permit, which
can be used in calls to getWaitTimeNanos(long)
to see how long to wait for the operation to be ready.long getWaitTimeNanos(long permit)
permit
- the permit returned by acquire()
static RateLimiter createRateLimiter(long permitsPerSecond)
permitsPerSecond
- permits per secondCopyright © 2023. All Rights Reserved.