public final class BasicCounter extends Object implements CounterSupplier
CounterSupplier
.
Counters must be started before they are first incremented.
Once they have stopped they cannot be started again.Constructor and Description |
---|
BasicCounter()
Creates a counter with an initial count of 0.
|
Modifier and Type | Method and Description |
---|---|
long |
getCount()
This will return the value of the counter or an undefined value if never started.
|
StatisticState |
getState()
Returns the current state of the supplier.
|
void |
increment()
Increments the counter by
1 |
void |
increment(long stepSize)
Increments the counter by the specified step size
|
CounterSupplier |
snapshot()
Returns a snapshot of this statistic.
|
void |
start()
Places the counter in the
StatisticState.ACTIVE . |
void |
stop()
Places the counter in the stopped state.
|
public BasicCounter()
increment()
for the first time,
start()
must be called.public void start()
StatisticState.ACTIVE
.IllegalStateException
- if the counter is already
started or has finishedpublic void stop()
finally
block.public StatisticState getState()
StatisticSupplier
getState
in interface StatisticSupplier
public void increment()
1
public void increment(long stepSize)
stepSize
- the amount by which to incrementpublic CounterSupplier snapshot()
StatisticSupplier
snapshot
in interface CounterSupplier
snapshot
in interface StatisticSupplier
public long getCount()
CounterSupplier
getCount
in interface CounterSupplier
Copyright © 2024 Actian Corporation. All rights reserved.