java.lang.Objectjavax.realtime.HighResolutionTime
javax.realtime.RelativeTime
javax.realtime.RationalTime
public class RationalTime
An object that represents a time interval milliseconds/103 + nanoseconds/109 seconds long that is divided into subintervals by some frequency. This is generally used in periodic events, threads, and feasibility analysis to specify periods where there is a basic period that must be adhered to strictly (the interval), but within that interval the periodic events are supposed to happen frequency times, as uniformly spaced as possible, but clock and scheduling jitter is moderately acceptable.
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. All Implemented Interfaces: java.lang.Comparable
| Constructor Summary | |
|---|---|
RationalTime(int frequency)
Deprecated. 1.0.1 |
|
RationalTime(int frequency,
long millis,
int nanos)
Deprecated. 1.0.1 |
|
RationalTime(int frequency,
RelativeTime interval)
Deprecated. 1.0.1 |
|
| Method Summary | |
|---|---|
AbsoluteTime |
absolute(Clock clock,
AbsoluteTime destination)
Deprecated. 1.0.1 |
void |
addInterarrivalTo(AbsoluteTime destination)
Deprecated. 1.0.1 |
int |
getFrequency()
Deprecated. 1.0.1 |
RelativeTime |
getInterarrivalTime()
Deprecated. 1.0.1 |
RelativeTime |
getInterarrivalTime(RelativeTime dest)
Deprecated. 1.0.1 |
void |
set(long millis,
int nanos)
Deprecated. 1.0.1 |
void |
setFrequency(int frequency)
Deprecated. 1.0.1 |
java.lang.String |
toString()
Deprecated. 1.0.1 |
| Methods inherited from class javax.realtime.RelativeTime |
|---|
absolute, add, add, add, add, relative, relative, subtract, subtract |
| Methods inherited from class javax.realtime.HighResolutionTime |
|---|
clone, compareTo, compareTo, equals, equals, getClock, getMilliseconds, getNanoseconds, hashCode, set, set, waitForObject |
| Methods inherited from class java.lang.Object |
|---|
finalize, getClass, notify, notifyAll, wait, wait, wait |
| Constructor Detail |
|---|
public RationalTime(int frequency)
RationalTime.
Equivalent to new RationalTime(1000, 0, frequency)essentially a cycles-per-second value.
java.lang.IllegalArgumentException - Thrown if frequency is less than or equal to zero.
public RationalTime(int frequency,
long millis,
int nanos)
RationalTime.
All arguments must be greater than or equal to zero.
frequency - The frequency value.millis - The milliseconds value.nanos - The nanoseconds value.
java.lang.IllegalArgumentException - If any of the argument values are less than zero, or
if frequency is equal to zero.
public RationalTime(int frequency,
RelativeTime interval)
RationalTime from the given RelativeTime.
frequency - The frequency value.interval - The given instance of RelativeTime.
java.lang.IllegalArgumentException - If either of the argument values are less than zero, or
if frequency is equal to zero.| Method Detail |
|---|
public AbsoluteTime absolute(Clock clock,
AbsoluteTime destination)
this to an absolute time.
absolute in class RelativeTimeclock - The reference clock. If null, Clock.getRealTimeClock() is used.destination - A reference to the destination instance.
AbsoluteTime conversion in
dest if dest is not null,
otherwise the result is returned in a newly allocated object.
It is associated with the clock parameter.public void addInterarrivalTo(AbsoluteTime destination)
this to an AbsoluteTime
It is almost the same dest.add(this, dest) except
that it accounts for (i.e. divides by) the frequency.
addInterarrivalTo in class RelativeTimedestination - A reference to the destination instance.public int getFrequency()
frequency.
frequency as an integer.public RelativeTime getInterarrivalTime()
RelativeTime.
getInterarrivalTime in class RelativeTimeRelativeTime with the same
interval as this.public RelativeTime getInterarrivalTime(RelativeTime dest)
RelativeTime.
getInterarrivalTime in class RelativeTimedest - Result is stored in dest and returned, if null, a new object is returned.
public void set(long millis,
int nanos)
set in class HighResolutionTimemillis - The new value for the millisecond field.nanos - The new value for the nanosecond field.public void setFrequency(int frequency)
frequency field.
frequency - The new value for the frequency.
java.lang.IllegalArgumentException - Thrown if frequency is less than or equal to zero.public java.lang.String toString()
this.
The string shall be a decimal representation of the frequency, milliseconds and nanosecond values; formatted as follows "(100, 2251 ms, 750000 ns)"
toString in class RelativeTimethis.