|
Oracle® Coherence Java API Reference v3.5.3 E15583-01 |
|||||||
| PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||
| SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD | |||||||
java.lang.Objectcom.tangosol.util.SafeClock
public class SafeClock
SafeClock maintains a "safe" time in milliseconds.
Unlike theSystem.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()
Create a new SafeClock with the default maximum expected jitter as specified by the "tangosol.coherence.safeclock.jitter" system property. |
|
SafeClock(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() method. |
long |
getSafeTimeMillis()
Returns a "safe" current time in milliseconds. |
protected long |
getUnsafeTimeMillis()
Return the current unsafe time. |
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 long m_lJitter
public static final long DEFAULT_JITTER_THRESHOLD
| Constructor Detail |
|---|
public SafeClock()
public SafeClock(long lJitter)
lJitter - the maximum expected jitter in the underlying system clock| Method Detail |
|---|
public long getSafeTimeMillis()
public long getLastSafeTimeMillis()
getSafeTimeMillis() 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 getUnsafeTimeMillis()
protected long updateSafeTimeMillis(long ldtUnsafe)
ldtUnsafe - the unsafe current time in milliseconds
|
Oracle® Coherence Java API Reference v3.5.3 E15583-01 |
|||||||
| PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||
| SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD | |||||||