-
- All Known Implementing Classes:
DefaultExecutionContext
public interface ExecutionContext
An optional context available from theRoot
lookup 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.ACTIVE
andExecutionContext.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 interface
ExecutionContext.ClockListener
Listener called on clock time updates.static class
ExecutionContext.State
Possible states of a Root.static interface
ExecutionContext.StateListener
Listener called on state changes.
-
Method Summary
All Methods Instance Methods Abstract Methods Default Methods Modifier and Type Method Description void
addClockListener(ExecutionContext.ClockListener listener)
Add a listener for clock changes.void
addStateListener(ExecutionContext.StateListener listener)
Add a listener for state changes.default OptionalLong
getPeriod()
Get the optional update period, if the Root implementation guarantees to update clock time at a fixed frequency.long
getStartTime()
Get the clock time in nanoseconds when the Root last became active.ExecutionContext.State
getState()
Get the current state of the Root.long
getTime()
Get the current Root local time in nanoseconds, relative to the RootHub clock.void
removeClockListener(ExecutionContext.ClockListener listener)
Remove an existing clock listener.void
removeStateListener(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
-
-