java.lang.Object
org.praxislive.base.DefaultExecutionContext
- All Implemented Interfaces:
ExecutionContext
Default implementation of
ExecutionContext for use with
AbstractRoot-
Nested Class Summary
Nested classes/interfaces inherited from interface org.praxislive.core.ExecutionContext
ExecutionContext.ClockListener, ExecutionContext.State, ExecutionContext.StateListener -
Constructor Summary
Constructors -
Method Summary
Modifier and TypeMethodDescriptionvoidAdd a listener for clock changes.voidAdd a listener for state changes.longGet the clock time in nanoseconds when the Root last became active.getState()Get the current state of the Root.longgetTime()Get the current Root local time in nanoseconds, relative to the RootHub clock.voidRemove an existing clock listener.voidRemove 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, waitMethods inherited from interface org.praxislive.core.ExecutionContext
getPeriod
-
Constructor Details
-
DefaultExecutionContext
public DefaultExecutionContext(long time) Create a DefaultExecutionContext- Parameters:
time- initial clock time / start time
-
-
Method Details
-
addStateListener
Description copied from interface:ExecutionContextAdd a listener for state changes.- Specified by:
addStateListenerin interfaceExecutionContext- Parameters:
listener- state listener, may not be null
-
removeStateListener
Description copied from interface:ExecutionContextRemove an existing state listener.- Specified by:
removeStateListenerin interfaceExecutionContext- Parameters:
listener- state listener to remove
-
addClockListener
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
Description copied from interface:ExecutionContextRemove an existing clock listener.- Specified by:
removeClockListenerin interfaceExecutionContext- Parameters:
listener- clock listener to remove
-
updateState
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
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
-