public interface StateMachine
A state machine consists of a set of states and transition rules between
those states. Transitions are triggered by events. Events can be issued
event(String) A transition always has a target state (i.e.
the state the state machine should switch to during the transition) and a set
of side effects. These can be further events to be triggered or commands that
should be issued. Events (both external and internal) are collected in an
event queue and processed asynchronously by the state machine. Commands
triggered by transitions are collected in a command queue that is accessible
from outside the state machine. This allows user code to collect these
commands and to process them. A cluster of state machines is handled
similarly to a single state machine but with multiple active states at once
(i.e. one active state per state machine) and all events are applied to all
internal state machines. Commands issued by any of the internal state
machines are all collected in a common command queue.
State machines must be started to be able to process events. Use
stop() to start or stop the state machine. A
stopped state machine can be restarted at any time. Restarting a state
machine simply resumes operation. A state machine can also be reset to the
initial state by calling
reset(). A reset will clear the event queue
and revert and reinitialise the state machine to its initial state. The
command queue remains unaffected as it is not considered as integral a part
to the state machine as the event queue is.
|Modifier and Type||Method and Description|
Adds a new event to the internal event queue
Provides the command queue associated with the state machine.
Resets the state machine to its initial state and clears the event queue.
Starts processing of the state machine event queue.
Stops processing of the state machine event queue.
void event(java.lang.String event)
event- the event to issue. may not be
BlockingQueue.take()on the queue to access the commands.
java.lang.IllegalStateException- the state machine is already running
java.lang.IllegalStateException- the state machine is not running
event(String)while the reset is in progress.
Copyright © 2017. All Rights Reserved.