public class RateLimiter extends Object implements IRateLimiter
| Constructor and Description |
|---|
RateLimiter(int requests,
int milliseconds) |
| Modifier and Type | Method and Description |
|---|---|
int |
getMillisecondsBetweenLocks() |
boolean |
lock()
Call this BEFORE executing code that needs to be rate limited.
|
void |
unlock()
Call this AFTER executing code that needs to be rate limited.
|
public RateLimiter(int requests,
int milliseconds)
requests - the x in x requests per y millisecondsmilliseconds - the y in x requests per y millisecondspublic boolean lock()
IRateLimiterlock in interface IRateLimiterpublic void unlock()
IRateLimiterunlock in interface IRateLimiterpublic int getMillisecondsBetweenLocks()
getMillisecondsBetweenLocks in interface IRateLimiterCopyright © 2017. All rights reserved.