public abstract class Clock extends java.lang.Object implements Chronograph
A clock provides means to determine the current time (now) with a given resolution.
| Constructor and Description |
|---|
Clock()
Constructor to be called by subclasses of Clock.
|
| Modifier and Type | Method and Description |
|---|---|
RelativeTime |
getDrivePrecision()
Returns the resolution for driving events from this clock, i.e.
|
RelativeTime |
getDrivePrecision(RelativeTime dest)
Returns the resolution for driving events from this clock, i.e.
|
RelativeTime |
getEpochOffset()
Determines the time on the UTC clock when this chronograph was
zero.
|
RelativeTime |
getQueryPrecision()
Obtain the precision with which time can be read, i.e., the nominal
interval between ticks.
|
RelativeTime |
getQueryPrecision(RelativeTime dest)
Obtain the precision with which time can be read, i.e., the nominal
interval between ticks.
|
static Clock |
getRealtimeClock()
Returns the default RealtimeClock.
|
abstract RelativeTime |
getResolution()
Obtains the resolution of reading this clock, i.e.
|
AbsoluteTime |
getTime()
Determines the current time.
|
abstract AbsoluteTime |
getTime(AbsoluteTime time)
Obtain the current time.
|
static Clock |
getUniversalClock()
Returns the default UniversalClock.
|
static void |
setRealtimeClock(Clock clock)
Sets the system default realtime clock.
|
abstract void |
setResolution(RelativeTime resolution)
Sets the resolution of this time to the provided value.
|
static void |
setUniversalClock(Clock clock)
Sets the system default universal clock.
|
boolean |
wait(java.lang.Object rendezvous,
HighResolutionTime<?> deadline)
Generic wait function that waits for a waiting for a deadlime.
|
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, waitgetEpochOffset, isUpdated, lastSynchronized, lastSynchronizedpublic Clock()
Since this class is abstract, this constructor cannot be called from a class that is not a sub-class of Clock, it should therefore better be protected.
public static Clock getRealtimeClock()
For JamaicaVM, on systems that have a timer that is synchronized with the external world, this returns a RealtimeClock that is synchronized with the external world. On systems whose timer is not synchronized with the external world, the time of the returned RealtimeClock may be different to the time used by the external world (e.g., the epoch may start at system boot time).
public static void setRealtimeClock(Clock clock)
clock - To be used for the realtime clock. When null, the
default realtime clock is set to the original system default.public static Clock getUniversalClock()
For JamaicaVM, on systems that have a timer that is synchronized with the external world, this returns a UniversalClock that is synchronized with the external world. On systems whose timer is not synchronized with the external world, the time of the returned UniversalClock may be different to the time used by the external world (e.g., the epoch may start at system boot time).
public static void setUniversalClock(Clock clock)
clock - To be used for the universal clock. When null, the
default universal clock is set to the original system default.public RelativeTime getEpochOffset() throws StaticUnsupportedOperationException, UninitializedStateException
getEpochOffset in interface ChronographRelativeTime object in the current
execution context with the realtime clock as its chronograph
and containing time when this chronograph was zero.UninitializedStateException - when UTC time is not yet available.StaticUnsupportedOperationExceptionpublic abstract RelativeTime getResolution()
StaticUnsupportedOperationException - when getting the time
resolution is not supported for the given clock.public AbsoluteTime getTime()
ChronographgetTime in interface ChronographAbsoluteTime in the
current allocation context, representing the current time.
The returned object has this its chronograph.public abstract AbsoluteTime getTime(AbsoluteTime time)
AbsoluteTime is changed at some time between the invocation of the
method and the return of the method. This method will return an absolute
time value that represents this chronograph's notion of the absolute time.
For chronographs that do not measure calendar time, this absolute time may
not represent a wall clock time.getTime in interface Chronographtime - The instance of AbsoluteTime object which will be
updated in place.AbsoluteTime passed as parameter, or a new
object when dest is null. The returned object
represents the current time and is associated with this
chronograph.public abstract void setResolution(RelativeTime resolution)
resolution - the new resolution.StaticIllegalArgumentException - if parameter is null or
represents a negative or zero interval.StaticUnsupportedOperationException - when setting the time
resolution is not supported for the given clock.public RelativeTime getQueryPrecision(RelativeTime dest)
getQueryPrecision(RelativeTime) with null as an argument.getQueryPrecision in interface Chronographdest - the time object to fill.public RelativeTime getQueryPrecision()
getQueryPrecision(RelativeTime) with null as an argument.getQueryPrecision in interface Chronographpublic RelativeTime getDrivePrecision()
public RelativeTime getDrivePrecision(RelativeTime dest)
dest - A time object to fill.public boolean wait(java.lang.Object rendezvous,
HighResolutionTime<?> deadline)
throws java.lang.InterruptedException
rendezvous object to hold the
schedulable until the time has elapsed. The caller must be
synchronized on rendezvous. This is used
to implement both RealtimeThread.sleep(javax.realtime.Clock, javax.realtime.HighResolutionTime<?>) and
RealtimeThread.waitForNextRelease()rendezvous - an object to wait on until time has passed thus
letting the current thread to continue.deadline - The time when the wait should endtrue when deadline is reached and
false when interrupted before deadlinejava.lang.InterruptedExceptionaicas GmbH, Karlsruhe, Germany —www.aicas.com
Copyright © 2001-2024 aicas GmbH. All Rights Reserved.