java.io.Serializable
public class RateCounter extends AbstractRateCounter
Modifier and Type | Class | Description |
---|---|---|
class |
RateCounter.TimeSlot |
Constructor | Description |
---|---|
RateCounter(int limit,
java.time.Duration period) |
Modifier and Type | Method | Description |
---|---|---|
boolean |
countPulse() |
Register a pulse.
|
java.time.Duration |
getDuration() |
The duration set by the
AbstractRateCounter.reset(int, Duration) |
int |
getPulseLimit() |
The pulse limit set by the
AbstractRateCounter.reset(int, Duration) |
long |
millisecondsLeft() |
|
int |
pulsesLeft() |
Get the number of pulses left for the current time slot.
|
void |
reset(int limit,
java.time.Duration period) |
Set the time stol to a specified period and start counting pulses.
|
public void reset(int limit, java.time.Duration period)
AbstractRateCounter
reset
in class AbstractRateCounter
limit
- maximum puleses per slotperiod
- slot durationpublic java.time.Duration getDuration()
AbstractRateCounter
AbstractRateCounter.reset(int, Duration)
getDuration
in class AbstractRateCounter
Duration
public int getPulseLimit()
AbstractRateCounter
AbstractRateCounter.reset(int, Duration)
getPulseLimit
in class AbstractRateCounter
public int pulsesLeft()
AbstractRateCounter
pulsesLeft
in class AbstractRateCounter
public long millisecondsLeft()
public boolean countPulse()
AbstractRateCounter
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 AbstractRateCounter.countPulse()
does not count.
countPulse
in class AbstractRateCounter