public class TargetRateInput extends Object implements Input, ActivityDefObserver, RateLimiterProvider
This input will provide threadsafe access to a sequence of long values.
If the targetrate parameter is set on the activity def, then the rate of grants will also be throttled to that rate.
Changes to the cycles or the targetrate will affect the provided inputs. If the min or max cycle is changed, then these are re-applied first to the max cycle and then to the min cycle. If the min cycle is changed, then the next cycle value is set to the assigned min value. Otherwise, the cycle will continue as usual till it reaches the max value. The ability to reset the input while running by applying a new set of parameters makes it possible to re-trigger a sequence of inputs during a test.
This input, and Inputs in general do not actively prevent usage of values after the max value. They simply expose it to callers. It is up to the caller to check the value to determine when the input is deemed "used up."
| Constructor and Description |
|---|
TargetRateInput(ActivityDef activityDef) |
| Modifier and Type | Method and Description |
|---|---|
long |
getAsLong()
For the sake of efficiency, ActivityMotors that consume values from this interface should do a range check
after getting the value.
|
long |
getCurrent() |
long |
getInterval(long stride)
For the sake of efficiency, ActivityMotors that consume values from this interface
should do a range check after getting the value.
|
AtomicLong |
getMax() |
AtomicLong |
getMin() |
com.google.common.util.concurrent.RateLimiter |
getRateLimiter() |
void |
onActivityDefUpdate(ActivityDef activityDef) |
TargetRateInput |
setNextValue(long newValue) |
public TargetRateInput(ActivityDef activityDef)
public TargetRateInput setNextValue(long newValue)
public long getAsLong()
InputInput.getMax(), the motor should
take this as a signal to terminate gracefully with a log line indicating why.getAsLong in interface InputgetAsLong in interface LongSupplierpublic long getInterval(long stride)
InputgetMax, the motor should take this as a signal to terminate
gracefullly with a log line indicating why.getInterval in interface InputgetInterval in interface longIntervalSupplierstride - The width of the interval of numbers returnedpublic AtomicLong getMin()
public AtomicLong getMax()
public long getCurrent()
getCurrent in interface Inputpublic void onActivityDefUpdate(ActivityDef activityDef)
onActivityDefUpdate in interface ActivityDefObserverpublic com.google.common.util.concurrent.RateLimiter getRateLimiter()
getRateLimiter in interface RateLimiterProviderCopyright © 2017. All rights reserved.