com.zynaptic.reaction.util
Class JavaMonotonicClock
java.lang.Object
com.zynaptic.reaction.util.JavaMonotonicClock
- All Implemented Interfaces:
- MonotonicClockSource
public final class JavaMonotonicClock
- extends java.lang.Object
- implements MonotonicClockSource
Implements a monotonic clock source using the standard Java monotonic clock.
This monotonic clock variant makes use of the nanoTime system
call which provides a monotonic clock source on supported platforms. Note
that some platforms, including many standard Linux distributions, do not
provide native monotonic clock support and these should use the fixed up
monotonic clock source instead.
This simple implementation does not wrap correctly and will fail after 292
years of uptime.
|
Method Summary |
long |
getMsTime()
Gets the elapsed time since the monotonic clock source was initialised. |
void |
init()
Initialises the monotonic clock source. |
| Methods inherited from class java.lang.Object |
equals, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait |
JavaMonotonicClock
public JavaMonotonicClock()
getMsTime
public final long getMsTime()
- Description copied from interface:
MonotonicClockSource
- Gets the elapsed time since the monotonic clock source was initialised.
This method is called in order to obtain the current time, defined as the
integer number of milliseconds since the monotonic clock source was
initialised.
- Specified by:
getMsTime in interface MonotonicClockSource
- Returns:
- Returns the monotonic time since the clock was initialised,
specified in milliseconds. Returns invalid data if the clock has
not been initialised.
init
public final void init()
- Description copied from interface:
MonotonicClockSource
- Initialises the monotonic clock source. This method is called on startup by
the reactor in order to initialise the timebase clock. It resets the
current clock time value to 0 and then sets the timer counter running.
- Specified by:
init in interface MonotonicClockSource