com.croftsoft.core.animation.clock
Class HiResClock

java.lang.Object
  extended by com.croftsoft.core.animation.clock.HiResClock
All Implemented Interfaces:
Clock

public final class HiResClock
extends Object
implements Clock

A Clock with higher resolution than the system clock.

The system clock on some platforms has a granularity as poor as 50 or 60 milliseconds. For some applications, such as high frequency animation, this is insufficient. Film quality animation of 24 frames per second, for example, has a period of 41.667 milliseconds. This class provides high resolution timing with a granularity of one nanosecond.

The current implementation samples the system clock each time the method currentTimeNanos() is called. The period between method calls is then estimated using round robin windowed averaging. Assuming the method is called fairly periodically within a loop, the returned value will be the previous value plus the updated period estimate whenever the system clock has not been increased.

Since:
2002-03-11
Version:
2002-12-01
See Also:
SystemClock
Author:
David Wallace Croft

Constructor Summary
HiResClock()
           
 
Method Summary
 long currentTimeNanos()
           
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Constructor Detail

HiResClock

public HiResClock()
Method Detail

currentTimeNanos

public long currentTimeNanos()
Specified by:
currentTimeNanos in interface Clock

CroftSoft Javadoc

CroftSoft Core Javadoc (2008-09-28 20:58:02)