public class CachedNanoClock extends Object implements NanoClock
NanoClock that caches a timestamp which can be updated with update(long).
Instances are threadsafe with the read being volatile.
| Modifier and Type | Field and Description |
|---|---|
protected long |
timeNs
Time in nanoseconds.
|
| Constructor and Description |
|---|
CachedNanoClock() |
| Modifier and Type | Method and Description |
|---|---|
void |
advance(long nanos)
Advance the value of the timestamp in with release ordered semantics.
|
long |
nanoTime()
The number of ticks in nanoseconds the clock has advanced since starting.
|
void |
update(long timeNs)
Update the value of the timestamp with release memory ordered semantics.
|
public long nanoTime()
This method can only be used to measure elapsed time and is not related to any other notion of system or wall-clock time. The value returned represents nanoseconds since some fixed but arbitrary origin time (perhaps in the future, so values may be negative). The same origin is used by all invocations of this method in an instance of a Java virtual machine; other virtual machine instances are likely to use a different origin.
nanoTime in interface NanoClockSystem.nanoTime()public void update(long timeNs)
timeNs - value to update the timestamp.public void advance(long nanos)
nanos - to advance the timestamp.Copyright © 2014-2022 Real Logic Limited. All Rights Reserved.