|
|
|
|
|
by moody__
722 days ago
|
|
The "asynchronous state machine" name here is a bit strange, when searching for this term used elsewhere I couldn't find any formal definition what it is. Reading further in the README it looks like the author implies that it really just means a DFA? Not entirely sure. I'd also like to add the Plan 9 implementation[0], which also uses the properties of utf8 as part of its state machine and anecdotally has been quite performant when I've used it. [0] http://git.9front.org/plan9front/plan9front/107a7ba9717429ae... |
|
A synchronous state machine is one where the incoming stream of events is always "in sync" with the state transitions, in the following sense:
1. When an event happens, the state machine can transition to the next state and perform any necessary actions before the next event happens
2. After the the state machine has transitioned and performed any necessary actions, the program must wait for the next event to happen. It can't do anything else until it does.
An asynchronous state machine doesn't make the main program wait until the next event happens. It can go on and do other things in the meantime. It doesn't have to wait for then next event to arrive.
When the next event does arrive, the program pauses whatever else it is doing, and hands control back to the state machine, which process the event, and then hands control back over to the main program.