java.io.Serializable
RateCounter
public abstract class AbstractRateCounter
extends java.lang.Object
implements java.io.Serializable
Constructor | Description |
---|---|
AbstractRateCounter() |
Modifier and Type | Method | Description |
---|---|---|
abstract boolean |
countPulse() |
Register a pulse.
|
abstract java.time.Duration |
getDuration() |
The duration set by the
reset(int, Duration) |
abstract int |
getPulseLimit() |
The pulse limit set by the
reset(int, Duration) |
abstract int |
pulsesLeft() |
Get the number of pulses left for the current time slot.
|
abstract void |
reset(int limit,
java.time.Duration period) |
Set the time stol to a specified period and start counting pulses.
|
public abstract void reset(int limit, java.time.Duration period)
limit
- maximum puleses per slotperiod
- slot durationpublic abstract java.time.Duration getDuration()
reset(int, Duration)
Duration
public abstract int getPulseLimit()
reset(int, Duration)
public abstract int pulsesLeft()
public abstract boolean countPulse()
Important. A new slot must always be created with this call. The time between the end of the current slot and the
first call to the countPulse()
does not count.