com.threerings.media.timer
Class MillisTimer

java.lang.Object
  extended by com.threerings.media.timer.MillisTimer
All Implemented Interfaces:
MediaTimer

public class MillisTimer
extends Object
implements MediaTimer

Implements the MediaTimer interface using System.currentTimeMillis() to obtain timing information.

Note: System.currentTimeMillis() is notoriously inaccurate on different platforms. See bug report 4486109 for more information.

Also note: clock drift on Windows XP is especially pronounced and is exacerbated by the fact that WinXP periodically resyncs the system clock with the hardware clock, causing discontinuous jumps in the progression of time (usually backwards in time).


Field Summary
protected  long _resetStamp
          The time at which this timer was last reset.
 
Constructor Summary
MillisTimer()
           
 
Method Summary
 long getElapsedMicros()
          Returns the number of microseconds that have elapsed since the timer was created or last MediaTimer.reset().
 long getElapsedMillis()
          Returns the number of milliseconds that have elapsed since the timer was created or last MediaTimer.reset().
 void reset()
          Resets the timer's monotonically increasing value.
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Field Detail

_resetStamp

protected long _resetStamp
The time at which this timer was last reset.

Constructor Detail

MillisTimer

public MillisTimer()
Method Detail

reset

public void reset()
Description copied from interface: MediaTimer
Resets the timer's monotonically increasing value.

Specified by:
reset in interface MediaTimer

getElapsedMillis

public long getElapsedMillis()
Description copied from interface: MediaTimer
Returns the number of milliseconds that have elapsed since the timer was created or last MediaTimer.reset(). Note: the accuracy of this method is highly dependent on the timer implementation used.

Specified by:
getElapsedMillis in interface MediaTimer

getElapsedMicros

public long getElapsedMicros()
Description copied from interface: MediaTimer
Returns the number of microseconds that have elapsed since the timer was created or last MediaTimer.reset(). Note: the accuracy of this method is highly dependent on the timer implementation used.

Specified by:
getElapsedMicros in interface MediaTimer