Class AbstractIntervalTimer

java.lang.Object
com.google.apphosting.runtime.timer.AbstractIntervalTimer
All Implemented Interfaces:
Timer

public abstract class AbstractIntervalTimer extends Object implements Timer
AbstractIntervalTimer is common base class for Timer implementations 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 long
     
    protected boolean
     
    protected long
     
  • Constructor Summary

    Constructors
    Constructor
    Description
     
  • Method Summary

    Modifier and Type
    Method
    Description
    protected abstract long
     
    long
    Get the number of nanoseconds that elapsed between when the Timer was started and when it was stopped.
    protected double
    The fraction of the change in the underlying counter which will be attributed to this timer.
    void
    Start the timer running.
    void
    Stop the timer.
    void
    Update any internal state.
    protected void
    update(long currentValue)
     

    Methods inherited from class java.lang.Object

    clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
  • Field Details

    • running

      protected boolean running
    • startTime

      protected long startTime
    • cumulativeTime

      protected long cumulativeTime
  • Constructor Details

    • AbstractIntervalTimer

      public AbstractIntervalTimer()
  • Method Details

    • start

      public void start()
      Description copied from interface: Timer
      Start the timer running.
      Specified by:
      start in interface Timer
    • stop

      public void stop()
      Description copied from interface: Timer
      Stop the timer.
      Specified by:
      stop in interface Timer
    • update

      public void update()
      Description copied from interface: Timer
      Update any internal state. For example, some Timer implementations 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, see Timer.update().
      Specified by:
      update in interface Timer
    • getNanoseconds

      public long getNanoseconds()
      Description copied from interface: Timer
      Get the number of nanoseconds that elapsed between when the Timer was started and when it was stopped. Note that the return value has nanosecond precision but not necessarily nanosecond accuracy.
      Specified by:
      getNanoseconds in interface Timer
    • 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()