@Singleton public class JreTimeService extends AbstractTimeService
Constructor and Description |
---|
JreTimeService(listeners : SmartListenerCollection<TimeListener>)
Constructor.
|
Modifier and Type | Method and Description |
---|---|
boolean |
evolveTimeIfPossible([timeDelta : double])
Do a time evolution if the underlying service allows this action.
|
long |
getOSCurrentTime()
Replies the OS current time.
|
double |
getOSTimeFactor()
Replies the scaling factor between the agent time and the operating system time.
|
double |
getTime(timeUnit : TimeUnit)
Replies the current time.
|
TimeUnit |
getTimePrecision()
Replies the precision of the time that is assumed by this manager.
|
boolean |
setTimeIfPossible(time : double)
Change the time.
|
addTimeListener, fireTimeChanged, fromOSDuration, fromOSTime, removeTimeListener, toOSDuration, toOSTime
doStart, doStop, onStart, onStop
addListener, awaitRunning, awaitRunning, awaitTerminated, awaitTerminated, doCancelStart, failureCause, isRunning, notifyFailed, notifyStarted, notifyStopped, startAsync, state, stopAsync, toString
@Inject
public new
(listeners : SmartListenerCollection<TimeListener>)
listeners
- the empty collection of listeners that must be used by this service.@Pure
public def
getOSCurrentTime() : long
TimeService
getOSCurrentTime
in interface TimeService
getOSCurrentTime
in class AbstractTimeService
@Pure
public def
getTimePrecision() : TimeUnit
TimeService
Any duration that is below the time precision is ignored.
null
.@Pure
public def
getTime(timeUnit : TimeUnit) : double
TimeService
timeUnit
- if present, specifies the time unit of the value to reply. By default is it seconds.@Pure
public def
getOSTimeFactor() : double
TimeService
Consider time in the agent application. It may evolves at a different rate than the operating system time. The value that is replied by this function permits to determine the proportionally between the agent application time and the operating system time. A typical equation for representing this relation is: os time = OSTimeFactor * agent time.
public def
evolveTimeIfPossible([timeDelta : double]) : boolean
TimeService
timeDelta
- is the amount of time to consider for the evolution. If it is negative or zero,
a default amount will be selected by the time service.true
if time has evolved. Otherwise false
.public def
setTimeIfPossible(time : double) : boolean
TimeService
time
- the new time.true
if time has evolved. Otherwise false
.Copyright © 2021 the original authors or authors.