mirror of
https://github.com/urbit/shrub.git
synced 2024-12-19 16:51:42 +03:00
khan: cleanup
This commit is contained in:
parent
12b4c80cf1
commit
8ad57d8bd2
@ -2098,13 +2098,13 @@
|
||||
++ khan ^?
|
||||
|%
|
||||
+$ gift :: out result <-$
|
||||
$% [%avow p=(each cage [term tang])] :: thread result
|
||||
$% [%avow p=(each [mark noun] [term tang])] :: thread result
|
||||
==
|
||||
+$ task :: in request ->$
|
||||
$~ [%vega ~]
|
||||
$% $>(%born vane-task) :: new unix process
|
||||
[%done ~] :: socket closed
|
||||
[%fyrd =beak name=term data=*] :: run thread v0
|
||||
[%fyrd =desk name=term data=*] :: run thread v0
|
||||
$>(%trim vane-task) :: trim state
|
||||
$>(%vega vane-task) :: report upgrade
|
||||
==
|
||||
|
@ -49,27 +49,33 @@
|
||||
^- [(list move) _khan-gate]
|
||||
::
|
||||
=/ =task:khan ((harden task:khan) wrapped-task)
|
||||
?- -.task
|
||||
%vega
|
||||
[~ khan-gate]
|
||||
%trim
|
||||
[~ khan-gate]
|
||||
%done
|
||||
[~ khan-gate]
|
||||
?+ -.task [~ khan-gate]
|
||||
%born
|
||||
[~ khan-gate(unix-duct hen)]
|
||||
%fyrd
|
||||
=/ rid=@ta (rear (head hen))
|
||||
:: start the thread on %spider.
|
||||
::
|
||||
=/ wir=wire (head hen)
|
||||
=/ rid=@ta (rear wir)
|
||||
:: XX what if the client sends a duplicate rid?
|
||||
:: is this fine? should we inject some randomness?
|
||||
::
|
||||
=/ tid=@ta
|
||||
(cat 3 'khan-fyrd--' rid)
|
||||
=/ args
|
||||
:* ~ `tid [our q.beak.task %da now] name.task
|
||||
!>([~ ~zod])
|
||||
:* ~ `tid [our desk.task %da now] name.task
|
||||
:: XX can't do this:
|
||||
::
|
||||
:: !>(data.task)
|
||||
::
|
||||
:: special case for -hi:
|
||||
::
|
||||
!>(;;([~ arg=$@(who=ship [who=ship mez=tape])] data.task))
|
||||
==
|
||||
=/ start-moves=(list move)
|
||||
%+ turn
|
||||
:~ (watch-spider p.beak.task /thread-result/[tid])
|
||||
(start-spider p.beak.task %spider-start !>(args))
|
||||
:~ (watch-spider our /thread-result/[tid])
|
||||
(start-spider our %spider-start !>(args))
|
||||
==
|
||||
|=(=note ^-(move [hen %pass //g note]))
|
||||
[start-moves khan-gate]
|
||||
@ -80,7 +86,7 @@
|
||||
|= old=khan-state
|
||||
^+ khan-gate
|
||||
khan-gate(state old)
|
||||
:: +scry: view khan state
|
||||
:: +scry: nothing to see as yet
|
||||
::
|
||||
++ scry
|
||||
^- roon
|
||||
@ -88,6 +94,8 @@
|
||||
^- (unit (unit cage))
|
||||
~
|
||||
++ stay state
|
||||
:: +take: handle responses.
|
||||
::
|
||||
++ take
|
||||
|= [tea=wire hen=duct dud=(unit goof) hin=sign]
|
||||
^- [(list move) _khan-gate]
|
||||
@ -100,24 +108,30 @@
|
||||
?(%poke-ack %watch-ack)
|
||||
?~ p.p.hin [~ khan-gate]
|
||||
%- (slog u.p.p.hin)
|
||||
[~ khan-gate]
|
||||
:_ khan-gate
|
||||
[hen %give %avow %| -.p.hin u.p.p.hin]~
|
||||
::
|
||||
%fact
|
||||
=* cag cage.p.hin
|
||||
?+ p.cag !!
|
||||
?+ p.cag ~&(bad-fact+p.cag !!)
|
||||
%thread-fail
|
||||
%- (slog !<(tang q.cag))
|
||||
[~ khan-gate]
|
||||
=/ =tang !<(tang q.cag)
|
||||
%- (slog tang)
|
||||
:_ khan-gate
|
||||
[hen %give %avow %| p.cag tang]~
|
||||
::
|
||||
%thread-done
|
||||
:_ khan-gate
|
||||
=/ mov=move
|
||||
[hen %give %avow %& %tape !>(~)]
|
||||
~[mov]
|
||||
:: XX mark conversion
|
||||
::
|
||||
=/ res=* !<(* q.cag)
|
||||
[hen %give %avow %& %noun res]~
|
||||
==
|
||||
==
|
||||
::
|
||||
%khan
|
||||
:: XX unreachable?
|
||||
::
|
||||
!!
|
||||
==
|
||||
--
|
||||
|
Loading…
Reference in New Issue
Block a user