ch.bind.philib.util
Class LeakyBucket
java.lang.Object
ch.bind.philib.util.LeakyBucket
public final class LeakyBucket
- extends Object
An implementation of the leaky bucket pattern for throughput control.
- Author:
- Philipp Meinen
| Methods inherited from class java.lang.Object |
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait |
withLeakPerSecond
public static LeakyBucket withLeakPerSecond(double leakPerSecond,
long capacity)
withLeakIntervalMs
public static LeakyBucket withLeakIntervalMs(long leakIntervalMs,
long capacity)
withLeakIntervalUs
public static LeakyBucket withLeakIntervalUs(long leakIntervalUs,
long capacity)
withLeakIntervalNs
public static LeakyBucket withLeakIntervalNs(long leakIntervalNs,
long capacity)
getCapacity
public long getCapacity()
fill
public void fill(long amount)
canFill
public long canFill()
nextFillNs
public long nextFillNs()
nextFillUs
public long nextFillUs()
nextFillMs
public long nextFillMs()
sleepWhileNotFillable
public void sleepWhileNotFillable()
throws InterruptedException
- Throws:
InterruptedException
Copyright © 2013. All Rights Reserved.