public final class TokenBucket extends Object
| Modifier and Type | Method and Description |
|---|---|
int |
currentCapacity()
Retrieve a snapshot of the current number of tokens in the bucket.
|
int |
maxCapacity()
Retrieve the maximum capacity of the bucket configured when the bucket was created.
|
ReleaseResponse |
release(int amountToRelease)
Release a certain number of tokens back to this bucket.
|
String |
toString() |
AcquireResponse |
tryAcquire(int amountToAcquire)
Try to acquire a certain number of tokens from this bucket.
|
public AcquireResponse tryAcquire(int amountToAcquire)
AcquireResponse.acquisitionFailed() returns true.public ReleaseResponse release(int amountToRelease)
public int currentCapacity()
AcquireResponse.capacityRemaining() returned by the tryAcquire(int) method
whenever possible.public int maxCapacity()
Copyright © 2026. All rights reserved.