public abstract class TokenBucketStrategy extends Object implements IThrottleStrategy
| Modifier and Type | Field and Description |
|---|---|
protected long |
mCapacity |
protected long |
mNextRefillTime |
protected IRefillStrategy |
mRefillStrategy |
protected long |
mTokens |
| Constructor and Description |
|---|
TokenBucketStrategy(long pCapacity,
IRefillStrategy pRefillStrategy) |
| Modifier and Type | Method and Description |
|---|---|
long |
getCapacity() |
long |
getCurrentTokens() |
long |
getNextRefillTime() |
long |
getRefillIntervalInMillis() |
long |
getTokens() |
boolean |
isThrottled() |
boolean |
isThrottled(long n) |
protected abstract void |
updateTokens() |
protected final long mCapacity
protected final IRefillStrategy mRefillStrategy
protected volatile long mNextRefillTime
protected volatile long mTokens
public TokenBucketStrategy(long pCapacity,
IRefillStrategy pRefillStrategy)
public long getCapacity()
public long getNextRefillTime()
getNextRefillTime in interface IThrottleStrategypublic long getRefillIntervalInMillis()
public long getTokens()
public boolean isThrottled()
isThrottled in interface IThrottleStrategypublic boolean isThrottled(long n)
isThrottled in interface IThrottleStrategypublic long getCurrentTokens()
protected abstract void updateTokens()
lpezet