public class TimeoutStateMachine extends SynchronizedStateMachine
TimeoutEvent,
start(),
close()| Modifier and Type | Class and Description |
|---|---|
private class |
TimeoutStateMachine.TimeoutTask
The timeout task for scheduling the timeout transitions.
|
| Modifier and Type | Field and Description |
|---|---|
private boolean |
daemon
The inner thread used for timer is a daemon thread.
|
private java.lang.Object |
lastStateEnterId
The unique ID of the last state enter to forbid timeout in incorrect
state.
|
private java.lang.Object |
lastStateEnterIdNonLoop
The unique ID of the last state enter to forbid timeout in incorrect
state.
|
private java.util.Timer |
timer
The timer for scheduling timeout transitions.
|
loggerINITIAL_STATE_NAME| Constructor and Description |
|---|
TimeoutStateMachine(java.lang.String name)
Create the state machine.
|
TimeoutStateMachine(java.lang.String name,
boolean daemon)
Create the state machine.
|
| Modifier and Type | Method and Description |
|---|---|
void |
close()
Finish processing of the events and free all allocated resources.
|
(package private) java.lang.String |
getThreadName()
Helper method to get the name of the internally executed thread.
|
(package private) void |
notifyEnter(State previous,
Event event,
State current)
Process all state enter callbacks.
|
private void |
proccessTimeoutTransition(Transition timeoutTransition,
java.lang.Object stateEnterId,
java.lang.Object stateEnterIdNonLoop)
Process the timeout transition.
|
private void |
scheduleTimeoutTransition(boolean loopTransition,
TimeoutEvent event)
Schedule a new timeout transition, a state was entered.
|
void |
start()
Building of the processor is finished, prepare it to the events
processing.
|
getActiveState, getActiveStates, isInFinalState, processaddListener, addListener, addPreprocessor, addState, addTransition, easterEgg, getStates, getTransition, getTransitions, notifyExit, notifyTransition, setStartState, toStringgetNameprivate java.util.Timer timer
private final boolean daemon
private java.lang.Object lastStateEnterId
private java.lang.Object lastStateEnterIdNonLoop
public TimeoutStateMachine(java.lang.String name)
name - the name of the state machinepublic TimeoutStateMachine(java.lang.String name,
boolean daemon)
name - the name of the state machinedaemon - the inner thread used for timer is a daemon threadThreadjava.lang.String getThreadName()
public void start()
throws FsmException
Processorstart in interface Processorstart in interface StateMachinestart in class DeterministicStateMachineFsmException - if something failsProcessor.close()public void close()
ProcessorProcessor.close() should be
avoided. The behavior is not defined and may cause unpredictable
behavior, e.g. NullPointerException.close in interface java.lang.AutoCloseableclose in interface Processorclose in interface StateMachineclose in class DeterministicStateMachineProcessor.start()void notifyEnter(State previous, Event event, State current) throws FsmException
DeterministicStateMachinenotifyEnter in class DeterministicStateMachineprevious - the previous stateevent - the eventcurrent - the current stateFsmException - if something failsprivate void scheduleTimeoutTransition(boolean loopTransition,
TimeoutEvent event)
loopTransition - the transition was loop transitionevent - the timeout eventprivate void proccessTimeoutTransition(Transition timeoutTransition, java.lang.Object stateEnterId, java.lang.Object stateEnterIdNonLoop)
timeoutTransition - the transition with TimeoutEvent that should be processedstateEnterId - the unique ID of the state enterstateEnterIdNonLoop - the unique ID of the non-loop state enterCopyright 2013 Michal Turek, AnotherFSM.