|
||||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |
java.lang.Objectjavax.realtime.HighResolutionTime
Used to express time with nanosecond accuracy. This class is never
used directly: it is abstract and has no public constructors.
Instead, use one of its subclasses AbsoluteTime, RelativeTime, or
RationalTime. When an API is defined that has an HighResolutionTime
as a parameter, it can take either an absolute, relative, or
rational time and will do something appropriate. All of the
arithmetic functions come in both allocating and non-allocating
forms. The standard Java java.util.Date class uses milliseconds as
its basic unit in order to provide sufficient range for a wide
variety of applications. Real-time programming generally requires
nanosecond resolution, but even a 64 bit real-time clock based in
nanoseconds would be problematic in some situations, so a compound
format composed of 64 bits of millisecond timing, and 32 bits of
nanoseconds within a millisecond, was chosen.
Caution: This class is explicitly unsafe in multithreaded
situations when it is being changed. No synchronization is done. It
is assumed that users of this class who are mutating instances will
be doing their own synchronization at a higher level.
Method Summary | |
abstract AbsoluteTime |
absolute(Clock clock)
Convert to absolute time (with respect to a given clock). |
abstract AbsoluteTime |
absolute(Clock clock,
AbsoluteTime dest)
Convert to absolute time (with respect to a given clock). |
Object |
clone()
Clone this HighResolutionTime . |
int |
compareTo(HighResolutionTime time)
Compares this to another time object. |
int |
compareTo(Object time)
Compares this to another time object. |
boolean |
equals(HighResolutionTime time)
Determines whether this time equals a given other time. |
boolean |
equals(Object time)
Determines whether this time equals a given other time. |
Clock |
getClock()
Get the clock associated to this . |
long |
getMilliseconds()
Gets the milliseconds component associated with this time. |
int |
getNanoseconds()
Gets the nanoseconds component associated with this time. |
int |
hashCode()
|
abstract RelativeTime |
relative(Clock clock)
Convert to relative time (with respect to a given clock). |
abstract RelativeTime |
relative(Clock clock,
RelativeTime dest)
Convert to relative time (with respect to a given clock). |
void |
set(HighResolutionTime time)
Changes the time represented by the argument to some time between the invocation of the method and the return of the method. |
void |
set(long millis)
Sets the millisecond component of this to the given argument. |
void |
set(long millis,
int nanos)
Sets the millisecond and nanosecond components of this. |
static void |
waitForObject(Object target,
HighResolutionTime time)
Behaves exactly like target.wait() but with the enhancement that it waits with a precision of HighResolutionTime. Implementation Note: This method, as it is, really makes sense only if the time being passed is a RelativeTime (otherwise a clock should have been provided. |
Methods inherited from class java.lang.Object |
finalize, getClass, notify, notifyAll, toString, wait, wait, wait |
Method Detail |
public abstract AbsoluteTime absolute(Clock clock)
clock
- the clock that will convert the time
this
(if already an
absolute time)public abstract AbsoluteTime absolute(Clock clock, AbsoluteTime dest)
clock
- the clock that will convert the timedest
- the destination object
public abstract RelativeTime relative(Clock clock)
clock
- the clock that will convert the time
this
(if already a
relative time)public abstract RelativeTime relative(Clock clock, RelativeTime dest)
RTSJ compliance note: This signature disagrees with the online version of the RTSJ. The RTSJ appears to support this definition in spirit, as subclasses implement (in an attempted override) methods with this signature. We'll have to revisit this later.
clock
- the clock that will convert the timedest
- the destination object
public int compareTo(Object time)
compareTo
in interface Comparable
time
- the time against which "this" time has to be
compared.
public int compareTo(HighResolutionTime time)
time
- the time against which "this" time has to be
compared.
public boolean equals(HighResolutionTime time)
time
- the time value compared to this.
public boolean equals(Object time)
time
- the time value compared to this.
public final long getMilliseconds()
public final int getNanoseconds()
public int hashCode()
public void set(HighResolutionTime time)
time
- The HighResolutionTime which will be set to
represent the current time.public void set(long millis)
millis
- This value will be the value of the millisecond
component of this at the completion of the call. If millis is
negative the millisecond value of this is set to negative
value. Although logically this may represent time before the
epoch, invalid resultsmayoccur if a HighResolutionTime
representing time before the epoch is given as a parameter to
the methods.public void set(long millis, int nanos)
millis
- Value to set millisecond part of this. If millis
is negative the millisecond value of this is set to negative
value. Although logically this may represent time before the
epoch, invalid resultsmayoccur if a HighResolutionTime
representing time before the epoch is given as a parameter to
the methods.nanos
- Value to set nanosecond part of this. If nanos is
negative the millisecond value of this is set to negative
value. Although logically this may represent time before the
epoch, invalid resultsmayoccur if a HighResolutionTime
representing time before the epoch is given as a parameter to
the methods.public Clock getClock()
this
.
this
public static void waitForObject(Object target, HighResolutionTime time) throws InterruptedException
target
- The object on which to wait. The current thread
must have a lock on the object.time
- The time for which to wait. If this is
RelativeTime(0,0) then wait indefinitely.
InterruptedException
- If another threads interrupts
this thread while its waiting.public Object clone()
HighResolutionTime
.
|
||||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |