I am trying to design a state machine representation/notation that handles the transitions of multiple complicated objects over time and between threads and machines.
I want a good notation for state machines that is similar to EBNF.
I think rule engines become relevant when you think about complicated transitions of business processes.
I settled on this, it is inspired by prolog. It represents the state progression of an async/await thread pool and parallel state machines and forking and joining state machines.
A and B is a task variable and 1 is a thread number. The pipe symbol represents a transition from a group of states, all previous facts must match before progressing.
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)
I actually worked on a BPMN project once.The idea of this syntax is that your code would be reactive and you would have an API to retract or publish facts. The state machine handles scheduling.