Class DefaultExecutionContext

java.lang.Object
org.praxislive.base.DefaultExecutionContext
All Implemented Interfaces:
ExecutionContext

public class DefaultExecutionContext extends Object implements ExecutionContext
Default implementation of ExecutionContext for use with AbstractRoot
  • Constructor Details

    • DefaultExecutionContext

      public DefaultExecutionContext(long time)
      Create a DefaultExecutionContext
      Parameters:
      time - initial clock time / start time
  • Method Details

    • addStateListener

      public void addStateListener(ExecutionContext.StateListener listener)
      Description copied from interface: ExecutionContext
      Add a listener for state changes.
      Specified by:
      addStateListener in interface ExecutionContext
      Parameters:
      listener - state listener, may not be null
    • removeStateListener

      public void removeStateListener(ExecutionContext.StateListener listener)
      Description copied from interface: ExecutionContext
      Remove an existing state listener.
      Specified by:
      removeStateListener in interface ExecutionContext
      Parameters:
      listener - state listener to remove
    • addClockListener

      public void addClockListener(ExecutionContext.ClockListener listener)
      Description copied from interface: ExecutionContext
      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.
      Specified by:
      addClockListener in interface ExecutionContext
      Parameters:
      listener - clock listener, may not be null
    • removeClockListener

      public void removeClockListener(ExecutionContext.ClockListener listener)
      Description copied from interface: ExecutionContext
      Remove an existing clock listener.
      Specified by:
      removeClockListener in interface ExecutionContext
      Parameters:
      listener - clock listener to remove
    • updateState

      protected void updateState(long time, ExecutionContext.State state)
      Update the state. Will call all state listeners.
      Parameters:
      time - time of state change (if ACTIVE also the new start time)
      state - new state
      Throws:
      IllegalStateException - if attempting to reset to NEW from another state, or attempting to set to another state if current state is TERMINATED
    • getState

      public ExecutionContext.State getState()
      Description copied from interface: ExecutionContext
      Get the current state of the Root.
      Specified by:
      getState in interface ExecutionContext
      Returns:
      current state
    • updateClock

      protected void updateClock(long time)
      Update the clock time. Will call all clock listeners.
      Parameters:
      time -
    • getTime

      public long getTime()
      Description copied from interface: ExecutionContext
      Get the current Root local time in nanoseconds, relative to the RootHub clock.
      Specified by:
      getTime in interface ExecutionContext
      Returns:
      time in nanoseconds
    • getStartTime

      public long getStartTime()
      Description copied from interface: ExecutionContext
      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.
      Specified by:
      getStartTime in interface ExecutionContext
      Returns:
      clock time became active