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.
|
logger
INITIAL_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, process
addListener, addListener, addPreprocessor, addState, addTransition, easterEgg, getStates, getTransition, getTransitions, notifyExit, notifyTransition, setStartState, toString
getName
private 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 threadThread
java.lang.String getThreadName()
public void start() throws FsmException
Processor
start
in interface Processor
start
in interface StateMachine
start
in class DeterministicStateMachine
FsmException
- if something failsProcessor.close()
public void close()
Processor
Processor.close()
should be
avoided. The behavior is not defined and may cause unpredictable
behavior, e.g. NullPointerException
.close
in interface java.lang.AutoCloseable
close
in interface Processor
close
in interface StateMachine
close
in class DeterministicStateMachine
Processor.start()
void notifyEnter(State previous, Event event, State current) throws FsmException
DeterministicStateMachine
notifyEnter
in class DeterministicStateMachine
previous
- 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.