Class AbstractIntervalTimer
- java.lang.Object
-
- com.google.apphosting.runtime.timer.AbstractIntervalTimer
-
- All Implemented Interfaces:
Timer
public abstract class AbstractIntervalTimer extends Object implements Timer
AbstractIntervalTimeris common base class forTimerimplementations that base measure the change in some value between the point where the timer is started and the point where the timer is stopped.This class is thread-safe.
-
-
Field Summary
Fields Modifier and Type Field Description protected longcumulativeTimeprotected booleanrunningprotected longstartTime
-
Constructor Summary
Constructors Constructor Description AbstractIntervalTimer()
-
Method Summary
All Methods Instance Methods Abstract Methods Concrete Methods Modifier and Type Method Description protected abstract longgetCurrent()longgetNanoseconds()Get the number of nanoseconds that elapsed between when theTimerwas started and when it was stopped.protected doublegetRatio()The fraction of the change in the underlying counter which will be attributed to this timer.voidstart()Start the timer running.voidstop()Stop the timer.voidupdate()Update any internal state.protected voidupdate(long currentValue)
-
-
-
Method Detail
-
start
public void start()
Description copied from interface:TimerStart the timer running.
-
stop
public void stop()
Description copied from interface:TimerStop the timer.
-
update
public void update()
Description copied from interface:TimerUpdate any internal state. For example, someTimerimplementations may take snapshots of data that may be unavailable in the future. Clients should call this method periodically to qensure that any state is being updated. For an example, seeTimer.update().
-
getNanoseconds
public long getNanoseconds()
Description copied from interface:TimerGet the number of nanoseconds that elapsed between when theTimerwas started and when it was stopped. Note that the return value has nanosecond precision but not necessarily nanosecond accuracy.- Specified by:
getNanosecondsin interfaceTimer
-
getRatio
protected double getRatio()
The fraction of the change in the underlying counter which will be attributed to this timer. By default, 100% of it.
-
update
protected void update(long currentValue)
-
getCurrent
protected abstract long getCurrent()
-
-