Package com.tangosol.util
Class SafeClock
java.lang.Object
java.util.concurrent.atomic.AtomicBoolean
com.oracle.coherence.common.util.SafeClock
com.tangosol.util.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:
-
Field Summary
Fields inherited from class com.oracle.coherence.common.util.SafeClock
DEFAULT_JITTER_THRESHOLD, INSTANCE, m_ldtLastSafe, m_ldtLastUnsafe, m_lJitter
-
Constructor Summary
-
Method Summary
Methods inherited from class com.oracle.coherence.common.util.SafeClock
getLastSafeTimeMillis, getSafeTimeMillis, getSafeTimeMillis, updateSafeTimeMillis
Methods inherited from class java.util.concurrent.atomic.AtomicBoolean
compareAndExchange, compareAndExchangeAcquire, compareAndExchangeRelease, compareAndSet, get, getAcquire, getAndSet, getOpaque, getPlain, lazySet, set, setOpaque, setPlain, setRelease, toString, weakCompareAndSet, weakCompareAndSetAcquire, weakCompareAndSetPlain, weakCompareAndSetRelease, weakCompareAndSetVolatile
-
Constructor Details
-
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 timelJitter
- the maximum expected jitter in the underlying system clock
-