ch.bind.philib.util
public final class LeakyBucket extends Object
| Modifier and Type | Method and Description |
|---|---|
long |
canTake() |
long |
canTake(long timeNs) |
long |
getCapacity() |
long |
nextTakeMs() |
long |
nextTakeNs() |
long |
nextTakeNs(long timeNs) |
long |
nextTakeUs() |
void |
sleepUntilAvailable() |
void |
take(long amount) |
void |
take(long amount,
long timeNs) |
static LeakyBucket |
withTakeIntervalMs(long takeIntervalMs,
long capacity) |
static LeakyBucket |
withTakeIntervalNs(long takeIntervalNs,
long capacity) |
static LeakyBucket |
withTakeIntervalUs(long takeIntervalUs,
long capacity) |
static LeakyBucket |
withTakesPerSecond(double takesPerSecond,
long capacity) |
public static LeakyBucket withTakesPerSecond(double takesPerSecond, long capacity)
public static LeakyBucket withTakeIntervalMs(long takeIntervalMs, long capacity)
public static LeakyBucket withTakeIntervalUs(long takeIntervalUs, long capacity)
public static LeakyBucket withTakeIntervalNs(long takeIntervalNs, long capacity)
public long getCapacity()
public void take(long amount)
public void take(long amount,
long timeNs)
public long canTake()
public long canTake(long timeNs)
timeNs - a relative timestamp as provided by System.nanoTime() and not
System.currentTimeMillis().public long nextTakeNs()
public long nextTakeNs(long timeNs)
timeNs - a relative timestamp as provided by System.nanoTime() and not
System.currentTimeMillis().public long nextTakeUs()
public long nextTakeMs()
public void sleepUntilAvailable()
throws InterruptedException
InterruptedExceptionCopyright © 2014. All Rights Reserved.