khan: cleanup
only store metadata in the persistent map. just enough to support
(eventual) thread cancellation and output mark lookup.
try to delete thread state at other failure points not covered by
%kick.
reflect back the passed output mark rather than form.dais. not sure
about this one yet.
== ==
+$ khan-state
$: %0
- unix-duct=duct
- out-dais=(map duct dais:clay)
+ hey=duct :: current unix duct
+ run=(map duct thread-state) :: running threads
==
+ :: TODO move to lull
+ ::
+ +$ thread-state [tid=@ta mak=mark bek=beak]
--
=>
|%
%born
:- ~
%= khan-gate
- unix-duct hen
- out-dais *(map duct dais:clay)
+ hey hen
+ run *(map duct thread-state)
==
+ ::
%fyrd
=/ wir=wire (head hen)
=/ rid=@ta (rear wir)
=* fyd p.task
- ?: (~(has by out-dais) hen)
+ ?: (~(has by run) hen)
~|(%fyrd-duplicate-rid !!)
=/ tid=@ta
(cat 3 'khan-fyrd--' rid)
(start-spider our %spider-start !>(args))
==
|=(=note ^-(move [hen %pass //g note]))
- =. out-dais
- %+ ~(put by out-dais) hen
- (get-dais beak mark.fyd rof)
+ =. run (~(put by run) hen tid mark.fyd beak)
[start-moves khan-gate]
==
:: +load: migrate an old state to a new khan version
|= [tea=wire hen=duct dud=(unit goof) hin=sign]
^- [(list move) _khan-gate]
?^ dud
+ =. run (~(del by run) hen)
~|(%khan-take-dud (mean tang.u.dud))
?. ?=(%gall -.hin)
[~ khan-gate]
?+ -.p.hin [~ khan-gate]
?(%poke-ack %watch-ack)
?~ p.p.hin [~ khan-gate]
+ =. run (~(del by run) hen)
%- (slog u.p.p.hin)
:_ khan-gate
[hen %give %avow %| -.p.hin u.p.p.hin]~
::
%thread-done
:_ khan-gate
- =/ =dais:clay (~(got by out-dais) hen)
- =/ res=vase (vale:dais !<(* q.cag))
- :: XX store and reflect back mark?
- [hen %give %avow %& form.dais q.res]~
+ =/ tad=thread-state (~(got by run) hen)
+ =/ =dais:clay (get-dais bek.tad mak.tad rof)
+ =/ =vase (vale:dais q.q.cag)
+ [hen %give %avow %& mak.tad q.vase]~
==
%kick
- [~ khan-gate(out-dais (~(del by out-dais) hen))]
+ [~ khan-gate(run (~(del by run) hen))]
==
--
