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.
This commit is contained in:
Jōshin 2022-01-26 20:09:36 -08:00
parent aba5c0303d
commit 05a11d57b3
No known key found for this signature in database
GPG Key ID: A8BE5A9A521639D0

View File

@ -19,9 +19,12 @@
== == == ==
+$ khan-state +$ khan-state
$: %0 $: %0
unix-duct=duct hey=duct :: current unix duct
out-dais=(map duct dais:clay) run=(map duct thread-state) :: running threads
== ==
:: TODO move to lull
::
+$ thread-state [tid=@ta mak=mark bek=beak]
-- --
=> =>
|% |%
@ -63,14 +66,15 @@
%born %born
:- ~ :- ~
%= khan-gate %= khan-gate
unix-duct hen hey hen
out-dais *(map duct dais:clay) run *(map duct thread-state)
== ==
::
%fyrd %fyrd
=/ wir=wire (head hen) =/ wir=wire (head hen)
=/ rid=@ta (rear wir) =/ rid=@ta (rear wir)
=* fyd p.task =* fyd p.task
?: (~(has by out-dais) hen) ?: (~(has by run) hen)
~|(%fyrd-duplicate-rid !!) ~|(%fyrd-duplicate-rid !!)
=/ tid=@ta =/ tid=@ta
(cat 3 'khan-fyrd--' rid) (cat 3 'khan-fyrd--' rid)
@ -87,9 +91,7 @@
(start-spider our %spider-start !>(args)) (start-spider our %spider-start !>(args))
== ==
|=(=note ^-(move [hen %pass //g note])) |=(=note ^-(move [hen %pass //g note]))
=. out-dais =. run (~(put by run) hen tid mark.fyd beak)
%+ ~(put by out-dais) hen
(get-dais beak mark.fyd rof)
[start-moves khan-gate] [start-moves khan-gate]
== ==
:: +load: migrate an old state to a new khan version :: +load: migrate an old state to a new khan version
@ -112,12 +114,14 @@
|= [tea=wire hen=duct dud=(unit goof) hin=sign] |= [tea=wire hen=duct dud=(unit goof) hin=sign]
^- [(list move) _khan-gate] ^- [(list move) _khan-gate]
?^ dud ?^ dud
=. run (~(del by run) hen)
~|(%khan-take-dud (mean tang.u.dud)) ~|(%khan-take-dud (mean tang.u.dud))
?. ?=(%gall -.hin) ?. ?=(%gall -.hin)
[~ khan-gate] [~ khan-gate]
?+ -.p.hin [~ khan-gate] ?+ -.p.hin [~ khan-gate]
?(%poke-ack %watch-ack) ?(%poke-ack %watch-ack)
?~ p.p.hin [~ khan-gate] ?~ p.p.hin [~ khan-gate]
=. run (~(del by run) hen)
%- (slog u.p.p.hin) %- (slog u.p.p.hin)
:_ khan-gate :_ khan-gate
[hen %give %avow %| -.p.hin u.p.p.hin]~ [hen %give %avow %| -.p.hin u.p.p.hin]~
@ -133,12 +137,12 @@
:: ::
%thread-done %thread-done
:_ khan-gate :_ khan-gate
=/ =dais:clay (~(got by out-dais) hen) =/ tad=thread-state (~(got by run) hen)
=/ res=vase (vale:dais !<(* q.cag)) =/ =dais:clay (get-dais bek.tad mak.tad rof)
:: XX store and reflect back mark? =/ =vase (vale:dais q.q.cag)
[hen %give %avow %& form.dais q.res]~ [hen %give %avow %& mak.tad q.vase]~
== ==
%kick %kick
[~ khan-gate(out-dais (~(del by out-dais) hen))] [~ khan-gate(run (~(del by run) hen))]
== ==
-- --