|
Oracle® Coherence Java API Reference Release 12.1.2.0.3 E26043-02 |
|||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |
java.lang.Object
com.tangosol.util.SafeClock
public class 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.
Field Summary | |
---|---|
static long |
DEFAULT_JITTER_THRESHOLD The default jitter threshold. |
protected long |
m_ldtLastSafe The last known safe time value. |
protected long |
m_ldtLastUnsafe The last recorded unsafe time value. |
protected long |
m_lJitter The maximum expected jitter exposed by the underlying unsafe clock. |
Constructor Summary | |
---|---|
SafeClock(long ldtUnsafe) Create a new SafeClock with the default maximum expected jitter as specified by the "tangosol.coherence.safeclock.jitter" system property. |
|
SafeClock(long ldtUnsafe, long lJitter) Create a new SafeClock with the specified jitter threshold. |
Method Summary | |
---|---|
long |
getLastSafeTimeMillis() Returns the last "safe" time as computed by a previous call to the getSafeTimeMillis(long) method. |
long |
getSafeTimeMillis(long ldtUnsafe) Returns a "safe" current time in milliseconds. |
protected long |
updateSafeTimeMillis(long ldtUnsafe) Updates and returns a "safe" current time in milliseconds based on the "unsafe" time. |
Field Detail |
---|
protected long m_ldtLastSafe
protected long m_ldtLastUnsafe
protected final long m_lJitter
public static final long DEFAULT_JITTER_THRESHOLD
Constructor Detail |
---|
public SafeClock(long ldtUnsafe)
ldtUnsafe
- the current unsafe timepublic SafeClock(long ldtUnsafe, long lJitter)
ldtUnsafe
- the current unsafe timelJitter
- the maximum expected jitter in the underlying system clockMethod Detail |
---|
public final long getSafeTimeMillis(long ldtUnsafe)
ldtUnsafe
- the current unsafe timepublic final long getLastSafeTimeMillis()
getSafeTimeMillis(long)
method.
Note: Since the underlying field is non-volatile, the returned value is only guaranteed to be no less than the last value returned by getSafeTimeMillis() call on the same thread.
protected long updateSafeTimeMillis(long ldtUnsafe)
ldtUnsafe
- the unsafe current time in milliseconds
|
Oracle® Coherence Java API Reference Release 12.1.2.0.3 E26043-02 |
|||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |