com.j_spaces.kernel.time
Class RelativeTime

java.lang.Object
  extended by com.j_spaces.kernel.time.RelativeTime
All Implemented Interfaces:
ITimeProvider

public final class RelativeTime
extends Object
implements ITimeProvider

ITimeProvider implementation specifying a precise timer, which is not influenced by motions of the wall-clock time. This class contains methods related to millisecond-precision timing, particularly via the timeMillis() method. To measure time accurately, this method uses java.sun.Perf (since JDK1.4.2). The resolution of the timer is machine dependent.

Limitations:

  • sun.misc.Perf is not part of the core distribution, so there is no guarantee it will be present in future releases. More likely wont be present in JVMs distributed by other manufacturers.
  • Relative Time is currently limited to Windows OS.
  • Relative time is currently limited to in-memory space.

  • Constructor Summary
    RelativeTime()
              Returns a RelativeTime instance based on sun.misc.Perf precision.
     
    Method Summary
     long timeMillis()
              Returns the current value of the most precise available system timer, in milliseconds.
     
    Methods inherited from class java.lang.Object
    equals, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
     

    Constructor Detail

    RelativeTime

    public RelativeTime()
    Returns a RelativeTime instance based on sun.misc.Perf precision.

    Throws:
    RuntimeException - if failed to access to sun.misc.perf
    Method Detail

    timeMillis

    public long timeMillis()
    Returns the current value of the most precise available system timer, in milliseconds. This method is used to measure elapsed time and is not related to any other notion of system or wall-clock time.

    Specified by:
    timeMillis in interface ITimeProvider
    Returns:
    The current value of the system timer, in milliseconds.