|
|
|
|
|
by syngrog66
1099 days ago
|
|
A state machine (specifically a FSM) class is something I end up having to reinvent in every new language I've adopted. Such a useful pattern whose need comes up repeatedly. Especially in games/sims or in anything with a GUI. Since I've been making both for decades I have a lot of homegrown FSM classes sitting around. :-p |
|
The runtime is multithreaded and parallel.
The idea is to execute the following state machine:
This program waits until thread(s) is true in another thread until thread(r) is true, everything left of the equals symbol needs to be true before it passes to the next group of facts after the = symbol. Then it waits for "fact(variable)" to be fired, then when all those atoms are true, the state transitions past the pipe symbol and does a send(message) while the other thread does a receive(message) and then the process is repeated in the opposite direction. I've not shown it here, but you can wait for multiple facts to be true too.Here's a state machine for an (echo) server that is intended to be mapped to epoll or libiouring:
The curly brackets means parallel state machines that run independently, like a fork.