package anastore.client;

/**
 * A source for real-time time stamps used to ensure freshness.  This
 * is exposed as a public interface so that experiments can provide
 * their own notion of time that doesn't map to the actual wall clock.
 */
public interface TimeSource
{
    /**
     * Get the current time.  The absolute value of this is never
     * used, so its origin doesn't matter.  The values returned by
     * this method <i>must</i> be monotonically increasing, though
     * need not be strictly so.
     */
    public double currentTime();

    /**
     * A time source that uses the system wall-clock time and returns
     * times in seconds since the wall clock was instantiated.
     */
    public static final TimeSource WALL_CLOCK = new TimeSource() {
            private final long start = System.currentTimeMillis();

            public double currentTime()
            {
                return ((double)(System.currentTimeMillis()-start))/1000;
            }
        };
}
