Class SafeClock

  • All Implemented Interfaces:
    Serializable

    public class SafeClock
    extends com.oracle.coherence.common.util.SafeClock
    SafeClock maintains a "safe" time in milliseconds.

    Unlike the System.currentTimeMillis() this clock guarantees that the time never "goes back". More specifically, when queried twice on the same thread, the second query will never return a value that is less then the value returned by the first.

    If we detect the system clock moving backward, an attempt will be made to gradually compensate the safe clock (by slowing it down), so in the long run the safe time is the same as the system time.

    The SafeClock supports the concept of "clock jitter", which is a small time interval that the system clock could fluctuate by without a corresponding passage of wall time.

    Since:
    Coherence 3.6
    Author:
    mf 2009.12.09
    See Also:
    Serialized Form
    • Constructor Detail

      • SafeClock

        public SafeClock​(long ldtUnsafe)
        Create a new SafeClock with the default maximum expected jitter as specified by the "coherence.safeclock.jitter" system property.
        Parameters:
        ldtUnsafe - the current unsafe time
      • SafeClock

        public SafeClock​(long ldtUnsafe,
                         long lJitter)
        Create a new SafeClock with the specified jitter threshold.
        Parameters:
        ldtUnsafe - the current unsafe time
        lJitter - the maximum expected jitter in the underlying system clock