-
- All Known Implementing Classes:
DefaultExecutionContext
public interface ExecutionContextAn optional context available from theRootlookup providing the ability to query and listen for changes in root state or clock time.A Root will be initialized with
ExecutionContext.State.NEW, move to / betweenExecutionContext.State.ACTIVEandExecutionContext.State.IDLE, then move toExecutionContext.State.TERMINATED. A Root will not return to the NEW state, or any other state once terminated.Time is the local Root time relative to
RootHub.getClock(). Clock listeners are called whenever the Root's local time changes - the frequency of changes, and whether the frequency is fixed or variable, is Root implementation specific.
-
-
Nested Class Summary
Nested Classes Modifier and Type Interface Description static interfaceExecutionContext.ClockListenerListener called on clock time updates.static classExecutionContext.StatePossible states of a Root.static interfaceExecutionContext.StateListenerListener called on state changes.
-
Method Summary
All Methods Instance Methods Abstract Methods Default Methods Modifier and Type Method Description voidaddClockListener(ExecutionContext.ClockListener listener)Add a listener for clock changes.voidaddStateListener(ExecutionContext.StateListener listener)Add a listener for state changes.default OptionalLonggetPeriod()Get the optional update period, if the Root implementation guarantees to update clock time at a fixed frequency.longgetStartTime()Get the clock time in nanoseconds when the Root last became active.ExecutionContext.StategetState()Get the current state of the Root.longgetTime()Get the current Root local time in nanoseconds, relative to the RootHub clock.voidremoveClockListener(ExecutionContext.ClockListener listener)Remove an existing clock listener.voidremoveStateListener(ExecutionContext.StateListener listener)Remove an existing state listener.
-
-
-
Method Detail
-
addStateListener
void addStateListener(ExecutionContext.StateListener listener)
Add a listener for state changes.- Parameters:
listener- state listener, may not be null
-
removeStateListener
void removeStateListener(ExecutionContext.StateListener listener)
Remove an existing state listener.- Parameters:
listener- state listener to remove
-
addClockListener
void addClockListener(ExecutionContext.ClockListener listener)
Add a listener for clock changes. Listeners will be called every time the Root is active and its local time changes - the frequency of changes, and whether the frequency is fixed or variable, is Root implementation specific.- Parameters:
listener- clock listener, may not be null
-
removeClockListener
void removeClockListener(ExecutionContext.ClockListener listener)
Remove an existing clock listener.- Parameters:
listener- clock listener to remove
-
getTime
long getTime()
Get the current Root local time in nanoseconds, relative to the RootHub clock.- Returns:
- time in nanoseconds
-
getStartTime
long getStartTime()
Get the clock time in nanoseconds when the Root last became active. If the current state is not active, the return value is not valid.- Returns:
- clock time became active
-
getState
ExecutionContext.State getState()
Get the current state of the Root.- Returns:
- current state
-
getPeriod
default OptionalLong getPeriod()
Get the optional update period, if the Root implementation guarantees to update clock time at a fixed frequency.- Returns:
- optional update period
-
-