cmp.state
all-exec!
(all-exec! k)Handles the case where all state interfaces in a container are :executed. Proceeds depending on the old value of the ctrl interface.
all-executed
(all-executed v)Returns all-executed entrys of the given vector v.
Example:
(all-executed (stu/seq-idx->all-par
[{:seq-idx 0 :par-idx 0 :state :executed}
{:seq-idx 0 :par-idx 0 :state :ready}]
0))
;; =>
;; [{:seq-idx 0 :par-idx 0 :state :executed}]
ctrl-key->cmd-kw
(ctrl-key->cmd-kw k)Gets the cmd from the ctrl-k. Extracts the next-ctrl-cmd and make a keyword out of it.
de-observe!
(de-observe! k)Opposite of observe!: De-registers the state listener. The de-register pattern is derived from the key k (may be the ctrl-key or state-key). Resets the state interface afterwards.
dispatch
(dispatch k cmd)observe!s or de-observe!s depending on cmd. If an :error occurs the system is kept running (no de-observe). So, no restart is necessary. Just fix the problem and set the corresponding state from :error to ready and the processing goes on.
k->state-ks
(k->state-ks k)Returns the state keys for a given path.
(k->state-ks "wait@container@0")
ks->state-vec
(ks->state-vec ks)Builds the state map m belonging to a key set ks. m is introduced in order to keep the functions testable.
Example:
(ks->state-vec (k->state-ks "ref@container@0"))
next-map
(next-map v)The next-map function returns a map containing the next step to start. See cmp.state-test/next-map-i for examples how next-map should work.
Example:
(next-map [{:seq-idx 0 :par-idx 0 :state :executed}
{:seq-idx 0 :par-idx 1 :state :executed}
{:seq-idx 1 :par-idx 0 :state :executed}
{:seq-idx 2 :par-idx 0 :state :executed}
{:seq-idx 3 :par-idx 0 :state :working}
{:seq-idx 3 :par-idx 1 :state :ready}])
;; =>
;; {:seq-idx 3 :par-idx 1 :state :ready}
observe!
(observe! k)Registers a listener for the state-interface of a container or definitions struct. start-next! is the callback of this listener. The register pattern is derived from the key k (ctrl-key).
predecessors-executed?
(predecessors-executed? v i)Checks if the steps of v before i are all-executed?. Returns true for i equal to zero (or negative i)
start
(start mp-id)Registers a listener for the ctrl interface of the entire mp-id. The dispatch function becomes the listeners cb!.
start-next
(start-next v)Side effect free. Makes start-next! testable. Gets the state vector v and picks the next thing to do. The ctrl-key is derived from the first map in the the v.
start-next!
(start-next! v)start-next! choose the k of the upcomming tasks. Then the worker set the state to "working" which triggers the next call to start-next!: parallel tasks are started this way.
Side effects all around.
state-key->state-map
(state-key->state-map state-key)Builds a state-map by means of the info-map. The state value is assoced afet getting it with st/key->val.
stop
(stop mp-id)De-registers the listener for the ctrl interfaces of the mp-id. After stopping, the system will no longer react on changes (write events) at the ctrl interface.