Interface RateLimiter
-
Method Summary
Modifier and TypeMethodDescriptionvoidapplyRateSpec(SimRateSpec spec) Modify the rate of a running rate limiter.longblock()Block until it is time for the next operation, according to the nanoseconds per op as set byapplyRateSpec(SimRateSpec)getSpec()Get the rate spec that this rate limiter was created from.longReturn the system nanoseconds at the time when the last rate change was made active by a starting or restarting rate spec.Return the total number of nanoseconds behind schedule that this rate limiter is, including the full history across all rates.Return the total number of nanoseconds behind schedule that this rate limiter is, but only since the last time the rate spec has changed.double
-
Method Details
-
block
long block()Block until it is time for the next operation, according to the nanoseconds per op as set by
applyRateSpec(SimRateSpec)- Returns:
- the waittime as nanos behind schedule when this op returns.
The returned value is required to be greater than or equal to zero.
Note that accuracy of the returned value is limited by timing precision and calling overhead of the real time clock. It will not generally be better than microseconds. Also, some rate limiting algorithms are unable to efficiently track per-op waittime at speed due to bulk allocation mechanisms necessary to support higher rates.
-
getTotalWaitTimeDuration
Duration getTotalWaitTimeDuration()Return the total number of nanoseconds behind schedule that this rate limiter is, including the full history across all rates. When the rate is changed, this value is check-pointed to an accumulator and also included in any subsequent measurement.- Returns:
- nanoseconds behind schedule since the rate limiter was started
-
getWaitTimeDuration
Duration getWaitTimeDuration()Return the total number of nanoseconds behind schedule that this rate limiter is, but only since the last time the rate spec has changed. When the rate is changed, this value is check-pointed to an accumulator and also included in any subsequent measurement.- Returns:
- nanoseconds behind schedule since the rate limiter was started
-
getWaitTimeSeconds
double getWaitTimeSeconds() -
applyRateSpec
Modify the rate of a running rate limiter.- Parameters:
spec- The rate and burstRatio specification
-
getStartTime
long getStartTime()Return the system nanoseconds at the time when the last rate change was made active by a starting or restarting rate spec.- Returns:
- long nanoseconds
-
getSpec
SimRateSpec getSpec()Get the rate spec that this rate limiter was created from.- Returns:
- a RateSpec that describes this rate limiter
-