Class TimeService.SystemTimeService
java.lang.Object
org.jgroups.raft.util.TimeService.SystemTimeService
- All Implemented Interfaces:
TimeService
- Enclosing interface:
TimeService
Live implementation backed by the JVM time.
- Since:
- 2.0
- Author:
- José Bolina
-
Nested Class Summary
Nested classes/interfaces inherited from interface TimeService
TimeService.DisabledTimeService, TimeService.SystemTimeService -
Method Summary
Modifier and TypeMethodDescriptionlonginterval(long start) Computes the elapsed nanoseconds since a previously capturedTimeService.nanos()value.longnanos()Returns a monotonic nanosecond timestamp.now()Returns the current wall-clock time.
-
Method Details
-
now
Description copied from interface:TimeServiceReturns the current wall-clock time.Use this for human-readable timestamps. Do not use for latency measurement, wall-clock time is subject to NTP adjustments.
- Specified by:
nowin interfaceTimeService- Returns:
- the current instant, or
nullwhen the service is disabled
-
nanos
public long nanos()Description copied from interface:TimeServiceReturns a monotonic nanosecond timestamp.Capture a value with
nanos()at the start of an operation, then pass it toTimeService.interval(long)to compute the elapsed time. The absolute value has no meaning outside of interval computation.- Specified by:
nanosin interfaceTimeService- Returns:
- a monotonic nanosecond value, or
0when disabled
-
interval
public long interval(long start) Description copied from interface:TimeServiceComputes the elapsed nanoseconds since a previously capturedTimeService.nanos()value.Typical usage:
long start = timeService.nanos(); // ... operation ... long elapsedNanos = timeService.interval(start);- Specified by:
intervalin interfaceTimeService- Parameters:
start- a value previously returned byTimeService.nanos()- Returns:
- elapsed nanoseconds, or
0when disabled
-