org.apache.commons.monitoring.impl.values
Class ThreadSafeCounter
java.lang.Object
org.apache.commons.monitoring.impl.values.AbstractStatValue<Counter>
org.apache.commons.monitoring.impl.values.ThreadSafeCounter
- All Implemented Interfaces:
- Counter, StatValue
- Direct Known Subclasses:
- CompositeCounter
public class ThreadSafeCounter
- extends AbstractStatValue<Counter>
- implements Counter
Thread-safe implementation of Counter, based on
synchronized methods.
- Author:
- Nicolas De Loof
| Methods inherited from class org.apache.commons.monitoring.impl.values.AbstractStatValue |
addListener, fireValueChanged, getHits, getMax, getMin, getMonitor, getRole, getStandardDeviation, getUnit, normalize, removeListener, setMonitor |
| Methods inherited from class java.lang.Object |
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait |
| Methods inherited from interface org.apache.commons.monitoring.Counter |
getHits |
ThreadSafeCounter
public ThreadSafeCounter(Role<Counter> role)
get
public long get()
-
- Specified by:
get in interface StatValue
- Returns:
- the value
reset
public void reset()
- Description copied from interface:
StatValue
- reset the statValue
- Specified by:
reset in interface StatValue
set
public void set(long l,
Unit unit)
-
- Specified by:
set in interface StatValue
- Parameters:
l - the value to set
add
public void add(long delta,
Unit unit)
- Description copied from interface:
Counter
- Add value to the counter. Delta should not be negative (in such case a Gauge should be used).
- Specified by:
add in interface Counter
computeStats
protected void computeStats(long l)
- Overrides:
computeStats in class AbstractStatValue<Counter>
getMean
public double getMean()
- Description copied from class:
AbstractStatValue
-
- Specified by:
getMean in interface StatValue- Specified by:
getMean in class AbstractStatValue<Counter>
- Returns:
- the arithmetic mean value
getSquares
protected long getSquares()
- Specified by:
getSquares in class AbstractStatValue<Counter>
getSum
public long getSum()
- Specified by:
getSum in interface Counter- Specified by:
getSum in class AbstractStatValue<Counter>
- Returns:
- the sum of all set operations
Copyright © 2008 The Apache Software Foundation. All Rights Reserved.