Module com.github.akurilov.commons
Class RateThrottle
- java.lang.Object
-
- com.github.akurilov.commons.concurrent.throttle.RateThrottle
-
-
Constructor Summary
Constructors Constructor Description RateThrottle(double rateLimit)
-
Method Summary
All Methods Instance Methods Concrete Methods Modifier and Type Method Description booleantryAcquire()Request a permit about a thinginttryAcquire(int requiredCount)Request permits about a set of things
-
-
-
Method Detail
-
tryAcquire
public final boolean tryAcquire()
Description copied from interface:ThrottleRequest a permit about a thing- Specified by:
tryAcquirein interfaceThrottle- Returns:
- true if the thing should be passed, false otherwise
-
tryAcquire
public final int tryAcquire(int requiredCount)
Description copied from interface:ThrottleRequest permits about a set of things- Specified by:
tryAcquirein interfaceThrottle- Parameters:
requiredCount- how many permits is requested- Returns:
- how many permits are got
-
-