2 ms·
I recently designed a state machine serialization that is extremely powerful. My problem with most state machines is that they are tied to your implementation
by samsquire 4y ago
I recently designed a state machine serialization that is extremely powerful.
My problem with most state machines is that they are tied to your implementation language. And they are ad hoc.
An implementation programming language is itself a state machine - if you think of memory as being the states the machine can be in.
My state machine serialization supports and defines behaviour between concurrent threads and collections.
It defines a state machine between threads in async/await thread pool
Here is the serialization:
next_free_thread = 2
task(A) thread(1) assignment(A, 1) = running_on(A, 1) | paused(A, 1)
running_on(A, 1)
thread(1)
assignment(A, 1)
thread_free(next_free_thread) =
fork(A, B)
| send_task_to_thread(B, next_free_thread)
| running_on(B, 2) paused(B, 1)
running_on(A, 1)
| { yield(B, returnvalue) | paused(B, 2) }
{ await(A, B, returnvalue) | paused(A, 1) }
| send_returnvalue(B, A, returnvalue)
This defined a progression of a task on a thread and that can fork to a background task and then synchronize with a yield later on