org.apache.jackrabbit.mk.util
Class AscendingClock

java.lang.Object
  extended by org.apache.jackrabbit.mk.util.AscendingClock

public class AscendingClock
extends Object

A clock that normally returns the current system time since 1970, and is guaranteed to return ascending values. It returns ascending values even if the system time is changed, and never the same value twice. Worst case, it returns incrementing values. Unique nanosecond values are returned for system times between the years 1970 and 2554.


Constructor Summary
AscendingClock(long lastMillis)
          Create a new clock.
 
Method Summary
 long nanoTime()
          Get the current time, ensuring that the value is always larger than the last returned time, even if the system time was changed.
 long time()
          Get the current time, ensuring that the value is always larger than the last returned time, even if the system time was changed.
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Constructor Detail

AscendingClock

public AscendingClock(long lastMillis)
Create a new clock.

Parameters:
lastMillis - the time (the next returned value will be at least one bigger)
Method Detail

nanoTime

public long nanoTime()
Get the current time, ensuring that the value is always larger than the last returned time, even if the system time was changed. Worst case, this method will return the last returned value plus one.

Returns:
the time in nanoseconds since 1970-01-01 (UTC)

time

public long time()
Get the current time, ensuring that the value is always larger than the last returned time, even if the system time was changed. Worst case, this method will return the last returned value plus one.

Returns:
the time in milliseconds since 1970-01-01 (UTC)


Copyright © 2012 The Apache Software Foundation. All Rights Reserved.