Interface ExecutionContext

All Known Implementing Classes:
DefaultExecutionContext

public interface ExecutionContext
An optional context available from the Root 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 / between ExecutionContext.State.ACTIVE and ExecutionContext.State.IDLE, then move to ExecutionContext.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.

  • Method Details

    • 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

      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