public class OffsetEpochNanoClock extends Object implements EpochNanoClock
EpochNanoClock
that calculates an initial epoch nano time based on
System.currentTimeMillis()
and then uses that offset to adjust the return value of
System.nanoTime()
to the UNIX epoch.
The sample()
method can be used in order to reset these initial values if your system clock gets updated.
SystemEpochNanoClock
Constructor and Description |
---|
OffsetEpochNanoClock() |
OffsetEpochNanoClock(int maxMeasurementRetries,
long measurementThresholdNs,
long resampleIntervalNs)
Constructs the clock with custom configuration parameters.
|
Modifier and Type | Method and Description |
---|---|
boolean |
isWithinThreshold()
Gets whether the clock sampled the initial time offset accurately.
|
long |
nanoTime()
Time in nanoseconds since 1 Jan 1970 UTC.
|
void |
sample()
Explicitly resample the initial seeds.
|
public OffsetEpochNanoClock()
public OffsetEpochNanoClock(int maxMeasurementRetries, long measurementThresholdNs, long resampleIntervalNs)
maxMeasurementRetries
- the maximum number of times that this clock will attempt to re-sample the initial
time values.measurementThresholdNs
- the desired accuracy window for the initial clock samples.resampleIntervalNs
- the desired interval before the samples are automatically recalculated. The seed
recalculation enables the system to minimise clock drift if the system clock is
updated.public void sample()
public long nanoTime()
EpochNanoClock
nanoTime
in interface EpochNanoClock
public boolean isWithinThreshold()
Copyright © 2014-2020 Real Logic Limited. All Rights Reserved.