@Deprecated
public class TokenBucket
extends java.lang.Object
Modifier and Type | Field and Description |
---|---|
protected long |
current
Deprecated.
|
protected long |
max
Deprecated.
|
protected long |
nanosPerTick
Deprecated.
|
protected long |
timeLastTick
Deprecated.
|
Constructor and Description |
---|
TokenBucket(long max,
long nanosPerTick,
long initialValue)
Deprecated.
Create a token bucket.
|
Modifier and Type | Method and Description |
---|---|
void |
addTokens()
Deprecated.
|
void |
addTokensNoClip()
Deprecated.
Update the number of tokens according to elapsed time.
|
void |
blockingGrab(long tokens)
Deprecated.
|
void |
changeBucketSize(long newMax)
Deprecated.
|
void |
changeNanosAndBucketSize(long nanosPerTick,
long newMax)
Deprecated.
|
void |
changeNanosPerTick(long nanosPerTick)
Deprecated.
Change the number of nanos per tick.
|
long |
count()
Deprecated.
|
void |
forceGrab(long tokens)
Deprecated.
Remove tokens, without blocking, even if it causes the balance to go negative.
|
long |
getCount()
Deprecated.
Get the current number of available tokens.
|
long |
getNanosPerTick()
Deprecated.
|
void |
innerBlockingGrab(long tokens)
Deprecated.
Grab a bunch of tokens.
|
boolean |
instantGrab(long tokens)
Deprecated.
Either grab a bunch of tokens, or don't.
|
protected long |
offset()
Deprecated.
|
long |
partialInstantGrab(long tokens)
Deprecated.
Try to grab some tokens; if there aren't enough, grab all of them.
|
void |
recycle(long tokens)
Deprecated.
|
protected long current
protected long max
protected long timeLastTick
protected long nanosPerTick
public TokenBucket(long max, long nanosPerTick, long initialValue)
max
- The maximum size of the bucket, in tokens.nanosPerTick
- The number of nanoseconds between ticks.public boolean instantGrab(long tokens)
tokens
- The number of tokens to grab.public long partialInstantGrab(long tokens)
tokens
- The number of tokens to grab.public void forceGrab(long tokens)
tokens
- The number of tokens to remove.public long count()
public long getCount()
protected long offset()
public void blockingGrab(long tokens)
public void innerBlockingGrab(long tokens)
tokens
- The number of tokens to grab.public void recycle(long tokens)
public void changeNanosPerTick(long nanosPerTick)
nanosPerTick
- The new number of nanos per tick.public void changeBucketSize(long newMax)
public void changeNanosAndBucketSize(long nanosPerTick, long newMax)
public void addTokens()
public void addTokensNoClip()
public long getNanosPerTick()