A State Machine is a computation model used to design both computer programs and sequential logic circuits. It determines that an entity in a program can be in one of a finite number of states. The state it is in at any given time is called the current state. It can change from one state to another when initiated by a triggering event or condition; this is called a transition.
A state machine is an abstract machine, which possesses
- State a condition that when tested will be either true or false
- Transitions the result of true/false decision to another State
- Entry actions (what happens when a state is entered)
- Exit actions (analogous to entry actions)
As a result, a system can dynamically change its behavior based upon what it is currently doing and what input it receives - this allows state machines to model many types of systems. (An familiar example is Regex - Perl, Python, Tcl, .NET, and most other implementations use a state machine internally).
For example, consider a printer, which can be either waiting for a job, or printing it (states), and can start printing when a job is received and start waiting when it is done with the current job (transitions). Send notification is an exit action for the "Printing" state, to notify the print queue that it is done.
(The above diagram is in the SDL format - UML is also popular for representing state diagrams).
#Related tags coyote - The Coyote open source asynchronous programming framework