- java.lang.Object
-
- org.praxislive.base.DefaultExecutionContext
-
- All Implemented Interfaces:
ExecutionContext
public class DefaultExecutionContext extends Object implements ExecutionContext
Default implementation ofExecutionContextfor use withAbstractRoot
-
-
Nested Class Summary
-
Nested classes/interfaces inherited from interface org.praxislive.core.ExecutionContext
ExecutionContext.ClockListener, ExecutionContext.State, ExecutionContext.StateListener
-
-
Constructor Summary
Constructors Constructor Description DefaultExecutionContext(long time)Create a DefaultExecutionContext
-
Method Summary
All Methods Instance Methods Concrete 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.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.protected voidupdateClock(long time)Update the clock time.protected voidupdateState(long time, ExecutionContext.State state)Update the state.-
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
-
Methods inherited from interface org.praxislive.core.ExecutionContext
getPeriod
-
-
-
-
Method Detail
-
addStateListener
public void addStateListener(ExecutionContext.StateListener listener)
Description copied from interface:ExecutionContextAdd a listener for state changes.- Specified by:
addStateListenerin interfaceExecutionContext- Parameters:
listener- state listener, may not be null
-
removeStateListener
public void removeStateListener(ExecutionContext.StateListener listener)
Description copied from interface:ExecutionContextRemove an existing state listener.- Specified by:
removeStateListenerin interfaceExecutionContext- Parameters:
listener- state listener to remove
-
addClockListener
public void addClockListener(ExecutionContext.ClockListener listener)
Description copied from interface:ExecutionContextAdd 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:
addClockListenerin interfaceExecutionContext- Parameters:
listener- clock listener, may not be null
-
removeClockListener
public void removeClockListener(ExecutionContext.ClockListener listener)
Description copied from interface:ExecutionContextRemove an existing clock listener.- Specified by:
removeClockListenerin interfaceExecutionContext- 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:ExecutionContextGet the current state of the Root.- Specified by:
getStatein interfaceExecutionContext- 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:ExecutionContextGet the current Root local time in nanoseconds, relative to the RootHub clock.- Specified by:
getTimein interfaceExecutionContext- Returns:
- time in nanoseconds
-
getStartTime
public long getStartTime()
Description copied from interface:ExecutionContextGet 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:
getStartTimein interfaceExecutionContext- Returns:
- clock time became active
-
-