2019-09-26 22:00:11 +03:00
|
|
|
/- spider
|
2019-11-16 14:25:30 +03:00
|
|
|
/+ libstrand=strand, default-agent, verb
|
|
|
|
=, strand=strand:libstrand
|
2019-09-26 07:12:58 +03:00
|
|
|
|%
|
2019-11-19 07:36:21 +03:00
|
|
|
+$ card card:agent:gall
|
2019-11-16 14:25:30 +03:00
|
|
|
+$ thread thread:spider
|
|
|
|
+$ tid tid:spider
|
|
|
|
+$ input input:spider
|
|
|
|
+$ yarn (list tid)
|
|
|
|
+$ thread-form _*eval-form:eval:(strand ,vase)
|
2019-11-10 10:27:07 +03:00
|
|
|
+$ trie
|
2019-11-16 14:25:30 +03:00
|
|
|
$~ [*thread-form ~]
|
|
|
|
[=thread-form kid=(map tid trie)]
|
2019-11-10 10:27:07 +03:00
|
|
|
::
|
2019-11-16 04:20:56 +03:00
|
|
|
+$ trying ?(%find %build %none)
|
2019-11-10 06:09:02 +03:00
|
|
|
+$ state
|
2019-11-16 14:25:30 +03:00
|
|
|
$: starting=(map yarn [=trying =vase])
|
2019-11-10 10:27:07 +03:00
|
|
|
running=trie
|
2019-11-16 14:25:30 +03:00
|
|
|
tid=(map tid yarn)
|
2019-11-10 10:27:07 +03:00
|
|
|
==
|
|
|
|
::
|
|
|
|
+$ clean-slate
|
2019-11-16 14:25:30 +03:00
|
|
|
$: starting=(map yarn [=trying =vase])
|
|
|
|
running=(list yarn)
|
|
|
|
tid=(map tid yarn)
|
2019-11-10 10:27:07 +03:00
|
|
|
==
|
|
|
|
::
|
|
|
|
+$ start-args
|
2019-11-16 14:25:30 +03:00
|
|
|
[parent=(unit tid) use=(unit tid) file=term =vase]
|
2019-11-10 10:27:07 +03:00
|
|
|
--
|
|
|
|
::
|
|
|
|
:: Trie operations
|
|
|
|
::
|
|
|
|
|%
|
2019-11-16 14:25:30 +03:00
|
|
|
++ get-yarn
|
|
|
|
|= [=trie =yarn]
|
|
|
|
^- (unit =thread-form)
|
|
|
|
?~ yarn
|
|
|
|
`thread-form.trie
|
|
|
|
=/ son (~(get by kid.trie) i.yarn)
|
2019-11-10 10:27:07 +03:00
|
|
|
?~ son
|
|
|
|
~
|
2019-11-16 14:25:30 +03:00
|
|
|
$(trie u.son, yarn t.yarn)
|
|
|
|
::
|
|
|
|
++ get-yarn-children
|
|
|
|
|= [=trie =yarn]
|
|
|
|
^- (list ^yarn)
|
|
|
|
?~ yarn
|
|
|
|
(turn (tap-yarn trie) head)
|
|
|
|
=/ son (~(get by kid.trie) i.yarn)
|
2019-11-10 10:27:07 +03:00
|
|
|
?~ son
|
|
|
|
~
|
2019-11-16 14:25:30 +03:00
|
|
|
$(trie u.son, yarn t.yarn)
|
2019-11-10 10:27:07 +03:00
|
|
|
::
|
|
|
|
::
|
2019-11-16 14:25:30 +03:00
|
|
|
++ has-yarn
|
|
|
|
|= [=trie =yarn]
|
|
|
|
!=(~ (get-yarn trie yarn))
|
2019-11-10 10:27:07 +03:00
|
|
|
::
|
2019-11-16 14:25:30 +03:00
|
|
|
++ put-yarn
|
|
|
|
|= [=trie =yarn =thread-form]
|
2019-11-10 10:27:07 +03:00
|
|
|
^+ trie
|
2019-11-16 14:25:30 +03:00
|
|
|
?~ yarn
|
|
|
|
trie(thread-form thread-form)
|
|
|
|
=/ son (~(gut by kid.trie) i.yarn [*^thread-form ~])
|
2019-11-10 10:27:07 +03:00
|
|
|
%= trie
|
|
|
|
kid
|
2019-11-16 14:25:30 +03:00
|
|
|
%+ ~(put by kid.trie) i.yarn
|
|
|
|
$(trie son, yarn t.yarn)
|
2019-11-10 10:27:07 +03:00
|
|
|
==
|
|
|
|
::
|
2019-11-16 14:25:30 +03:00
|
|
|
++ del-yarn
|
|
|
|
|= [=trie =yarn]
|
2019-11-10 10:27:07 +03:00
|
|
|
^+ trie
|
2019-11-16 14:25:30 +03:00
|
|
|
?~ yarn
|
2019-11-10 10:27:07 +03:00
|
|
|
trie
|
|
|
|
|-
|
2019-11-16 14:25:30 +03:00
|
|
|
?~ t.yarn
|
|
|
|
trie(kid (~(del by kid.trie) i.yarn))
|
|
|
|
=/ son (~(get by kid.trie) i.yarn)
|
2019-11-10 10:27:07 +03:00
|
|
|
?~ son
|
|
|
|
trie
|
|
|
|
%= trie
|
|
|
|
kid
|
2019-11-16 14:25:30 +03:00
|
|
|
%+ ~(put by kid.trie) i.yarn
|
|
|
|
$(trie u.son, yarn t.yarn)
|
2019-11-10 06:09:02 +03:00
|
|
|
==
|
2019-11-10 10:27:07 +03:00
|
|
|
::
|
2019-11-16 14:25:30 +03:00
|
|
|
++ tap-yarn
|
|
|
|
=| =yarn
|
2019-11-10 10:27:07 +03:00
|
|
|
|= =trie
|
2019-11-16 14:25:30 +03:00
|
|
|
^- (list [=^yarn =thread-form])
|
2019-11-10 10:27:07 +03:00
|
|
|
%+ welp
|
2019-11-16 14:25:30 +03:00
|
|
|
?~ yarn
|
2019-11-10 10:27:07 +03:00
|
|
|
~
|
2019-11-16 14:25:30 +03:00
|
|
|
[(flop yarn) thread-form.trie]~
|
2019-11-10 10:27:07 +03:00
|
|
|
=/ kids ~(tap by kid.trie)
|
2019-11-16 14:25:30 +03:00
|
|
|
|- ^- (list [=^yarn =thread-form])
|
2019-11-10 10:27:07 +03:00
|
|
|
?~ kids
|
|
|
|
~
|
2019-11-16 14:25:30 +03:00
|
|
|
=/ next-1 ^$(yarn [p.i.kids yarn], trie q.i.kids)
|
2019-11-10 10:27:07 +03:00
|
|
|
=/ next-2 $(kids t.kids)
|
|
|
|
(welp next-1 next-2)
|
2019-09-26 07:12:58 +03:00
|
|
|
--
|
2019-11-10 10:27:07 +03:00
|
|
|
::
|
2019-11-19 07:36:21 +03:00
|
|
|
^- agent:gall
|
2019-11-07 09:19:32 +03:00
|
|
|
=| =state
|
|
|
|
=<
|
2019-11-15 23:46:11 +03:00
|
|
|
%+ verb |
|
2019-11-19 07:36:21 +03:00
|
|
|
|_ =bowl:gall
|
2019-11-10 10:27:07 +03:00
|
|
|
+* this .
|
2019-11-07 09:19:32 +03:00
|
|
|
spider-core +>
|
2019-11-10 10:27:07 +03:00
|
|
|
sc ~(. spider-core bowl)
|
|
|
|
def ~(. (default-agent this %|) bowl)
|
2019-09-26 07:12:58 +03:00
|
|
|
::
|
2019-11-07 09:19:32 +03:00
|
|
|
++ on-init on-init:def
|
2019-11-10 10:27:07 +03:00
|
|
|
++ on-save clean-state:sc
|
2019-11-10 06:09:02 +03:00
|
|
|
++ on-load
|
|
|
|
|= old-state=vase
|
2019-11-10 10:27:07 +03:00
|
|
|
=+ !<(=clean-slate old-state)
|
2019-11-16 14:25:30 +03:00
|
|
|
=. tid.state tid.clean-slate
|
|
|
|
=/ yarns=(list yarn)
|
2019-11-16 04:20:56 +03:00
|
|
|
%+ welp running.clean-slate
|
|
|
|
~(tap in ~(key by starting.clean-slate))
|
2019-11-10 06:09:02 +03:00
|
|
|
|- ^- (quip card _this)
|
2019-11-16 14:25:30 +03:00
|
|
|
?~ yarns
|
2019-11-10 06:09:02 +03:00
|
|
|
`this
|
2019-11-10 10:27:07 +03:00
|
|
|
=^ cards-1 state
|
2019-11-16 14:25:30 +03:00
|
|
|
(handle-stop-thread:sc (yarn-to-tid i.yarns) |)
|
2019-11-10 10:27:07 +03:00
|
|
|
=^ cards-2 this
|
2019-11-16 14:25:30 +03:00
|
|
|
$(yarns t.yarns)
|
2019-11-10 06:09:02 +03:00
|
|
|
[(weld cards-1 cards-2) this]
|
|
|
|
::
|
2019-11-07 09:19:32 +03:00
|
|
|
++ on-poke
|
2019-09-26 07:12:58 +03:00
|
|
|
|= [=mark =vase]
|
|
|
|
^- (quip card _this)
|
|
|
|
=^ cards state
|
2019-11-07 09:19:32 +03:00
|
|
|
?+ mark (on-poke:def mark vase)
|
2019-11-16 14:25:30 +03:00
|
|
|
%spider-input (on-poke-input:sc !<(input vase))
|
|
|
|
%spider-start (handle-start-thread:sc !<(start-args vase))
|
|
|
|
%spider-stop (handle-stop-thread:sc !<([tid ?] vase))
|
2019-09-26 07:12:58 +03:00
|
|
|
==
|
|
|
|
[cards this]
|
|
|
|
::
|
2019-11-07 09:19:32 +03:00
|
|
|
++ on-watch
|
2019-10-11 01:30:24 +03:00
|
|
|
|= =path
|
|
|
|
^- (quip card _this)
|
|
|
|
=^ cards state
|
2019-11-07 09:19:32 +03:00
|
|
|
?+ path (on-watch:def path)
|
2019-11-16 14:25:30 +03:00
|
|
|
[%thread @ *] (on-watch:sc t.path)
|
|
|
|
[%thread-result @ ~] (on-watch-result:sc i.t.path)
|
2019-10-11 01:30:24 +03:00
|
|
|
==
|
|
|
|
[cards this]
|
|
|
|
::
|
2019-11-07 09:19:32 +03:00
|
|
|
++ on-leave on-leave:def
|
|
|
|
++ on-peek
|
2019-09-29 07:44:31 +03:00
|
|
|
|= =path
|
|
|
|
^- (unit (unit cage))
|
2019-11-10 10:27:07 +03:00
|
|
|
?+ path (on-peek:def path)
|
|
|
|
[%x %tree ~]
|
2019-11-16 14:25:30 +03:00
|
|
|
``noun+!>((turn (tap-yarn running.state) head))
|
2019-11-10 10:27:07 +03:00
|
|
|
::
|
2019-11-16 04:20:56 +03:00
|
|
|
[%x %starting @ ~]
|
2019-11-16 14:25:30 +03:00
|
|
|
``noun+!>((has-yarn running.state (~(got by tid.state) i.t.t.path)))
|
2019-11-10 10:27:07 +03:00
|
|
|
::
|
|
|
|
[%x %saxo @ ~]
|
2019-11-16 14:25:30 +03:00
|
|
|
``noun+!>((~(got by tid.state) i.t.t.path))
|
2019-09-29 07:44:31 +03:00
|
|
|
==
|
|
|
|
::
|
2019-11-07 09:19:32 +03:00
|
|
|
++ on-agent
|
2019-11-19 07:36:21 +03:00
|
|
|
|= [=wire =sign:agent:gall]
|
2019-09-29 07:44:31 +03:00
|
|
|
^- (quip card _this)
|
|
|
|
=^ cards state
|
|
|
|
?+ wire !!
|
2019-11-16 14:25:30 +03:00
|
|
|
[%thread @ *] (on-agent:sc i.t.wire t.t.wire sign)
|
2019-09-29 07:44:31 +03:00
|
|
|
==
|
|
|
|
[cards this]
|
|
|
|
::
|
2019-11-07 09:19:32 +03:00
|
|
|
++ on-arvo
|
2019-09-26 07:12:58 +03:00
|
|
|
|= [=wire =sign-arvo]
|
|
|
|
^- (quip card _this)
|
|
|
|
=^ cards state
|
2019-11-07 09:19:32 +03:00
|
|
|
?+ wire (on-arvo:def wire sign-arvo)
|
2019-11-16 14:25:30 +03:00
|
|
|
[%thread @ *] (handle-sign:sc i.t.wire t.t.wire sign-arvo)
|
|
|
|
[%find @ ~] (handle-find:sc i.t.wire sign-arvo)
|
|
|
|
[%build @ ~] (handle-build:sc i.t.wire sign-arvo)
|
2019-09-26 07:12:58 +03:00
|
|
|
==
|
|
|
|
[cards this]
|
2019-11-16 14:25:30 +03:00
|
|
|
:: On unexpected failure, kill all outstanding strands
|
2019-09-29 07:44:31 +03:00
|
|
|
::
|
2019-11-16 04:20:56 +03:00
|
|
|
++ on-fail
|
|
|
|
|= [=term =tang]
|
|
|
|
^- (quip card _this)
|
2019-11-16 14:25:30 +03:00
|
|
|
%- (slog leaf+"spider crashed, killing all strands: {<term>}" tang)
|
2019-11-16 04:20:56 +03:00
|
|
|
(on-load on-save)
|
2019-09-26 07:12:58 +03:00
|
|
|
--
|
|
|
|
::
|
2019-11-19 07:36:21 +03:00
|
|
|
|_ =bowl:gall
|
2019-11-16 14:25:30 +03:00
|
|
|
++ on-poke-input
|
|
|
|
|= input
|
|
|
|
=/ yarn (~(got by tid.state) tid)
|
|
|
|
(take-input yarn ~ %poke cage)
|
2019-09-26 07:12:58 +03:00
|
|
|
::
|
2019-11-07 09:19:32 +03:00
|
|
|
++ on-watch
|
2019-11-16 14:25:30 +03:00
|
|
|
|= [=tid =path]
|
|
|
|
(take-input (~(got by tid.state) tid) ~ %watch path)
|
2019-10-11 01:30:24 +03:00
|
|
|
::
|
2019-11-10 06:09:02 +03:00
|
|
|
++ on-watch-result
|
2019-11-16 14:25:30 +03:00
|
|
|
|= =tid
|
2019-11-10 06:09:02 +03:00
|
|
|
^- (quip card ^state)
|
|
|
|
`state
|
|
|
|
::
|
2019-09-26 07:12:58 +03:00
|
|
|
++ handle-sign
|
2019-11-16 14:25:30 +03:00
|
|
|
|= [=tid =wire =sign-arvo]
|
|
|
|
=/ yarn (~(get by tid.state) tid)
|
|
|
|
?~ yarn
|
|
|
|
%- (slog leaf+"spider got sign for non-existent {<tid>}" ~)
|
2019-11-10 10:27:07 +03:00
|
|
|
`state
|
2019-11-16 14:25:30 +03:00
|
|
|
(take-input u.yarn ~ %sign wire sign-arvo)
|
2019-09-26 07:12:58 +03:00
|
|
|
::
|
2019-11-07 09:19:32 +03:00
|
|
|
++ on-agent
|
2019-11-19 07:36:21 +03:00
|
|
|
|= [=tid =wire =sign:agent:gall]
|
2019-11-16 14:25:30 +03:00
|
|
|
=/ yarn (~(get by tid.state) tid)
|
|
|
|
?~ yarn
|
|
|
|
%- (slog leaf+"spider got agent for non-existent {<tid>}" ~)
|
2019-11-10 10:27:07 +03:00
|
|
|
`state
|
2019-11-16 14:25:30 +03:00
|
|
|
(take-input u.yarn ~ %agent wire sign)
|
2019-09-29 07:44:31 +03:00
|
|
|
::
|
2019-11-16 14:25:30 +03:00
|
|
|
++ handle-start-thread
|
|
|
|
|= [parent-tid=(unit tid) use=(unit tid) file=term =vase]
|
2019-09-26 07:12:58 +03:00
|
|
|
^- (quip card ^state)
|
2019-11-16 14:25:30 +03:00
|
|
|
=/ parent-yarn=yarn
|
|
|
|
?~ parent-tid
|
2019-11-10 10:27:07 +03:00
|
|
|
/
|
2019-11-16 14:25:30 +03:00
|
|
|
(~(got by tid.state) u.parent-tid)
|
|
|
|
=/ new-tid (fall use (scot %uv (sham eny.bowl)))
|
|
|
|
=/ =yarn (snoc parent-yarn new-tid)
|
2019-11-10 10:27:07 +03:00
|
|
|
::
|
2019-11-16 14:25:30 +03:00
|
|
|
?: (has-yarn running.state yarn)
|
|
|
|
~| [%already-started yarn]
|
2019-09-26 07:12:58 +03:00
|
|
|
!!
|
2019-11-16 14:25:30 +03:00
|
|
|
?: (~(has by starting.state) yarn)
|
|
|
|
~| [%already-starting yarn]
|
2019-11-10 06:09:02 +03:00
|
|
|
!!
|
2019-11-12 08:36:32 +03:00
|
|
|
::
|
2019-11-16 14:25:30 +03:00
|
|
|
=: starting.state (~(put by starting.state) yarn [%find vase])
|
|
|
|
tid.state (~(put by tid.state) new-tid yarn)
|
2019-11-10 10:27:07 +03:00
|
|
|
==
|
2019-09-26 22:00:11 +03:00
|
|
|
=/ =card
|
2019-11-16 14:25:30 +03:00
|
|
|
=/ =schematic:ford [%path [our.bowl %home] %ted file]
|
|
|
|
[%pass /find/[new-tid] %arvo %f %build live=%.n schematic]
|
2019-09-29 07:44:31 +03:00
|
|
|
[[card ~] state]
|
|
|
|
::
|
|
|
|
++ handle-find
|
2019-11-16 14:25:30 +03:00
|
|
|
|= [=tid =sign-arvo]
|
2019-09-29 07:44:31 +03:00
|
|
|
^- (quip card ^state)
|
2019-11-16 14:25:30 +03:00
|
|
|
=/ =yarn (~(got by tid.state) tid)
|
2019-11-16 04:20:56 +03:00
|
|
|
=. starting.state
|
2019-11-16 14:25:30 +03:00
|
|
|
(~(jab by starting.state) yarn |=([=trying =vase] [%none vase]))
|
2019-09-29 07:44:31 +03:00
|
|
|
?> ?=([%f %made *] sign-arvo)
|
|
|
|
?: ?=(%incomplete -.result.sign-arvo)
|
2019-11-16 14:25:30 +03:00
|
|
|
(thread-fail-not-running tid %find-thread-incomplete tang.result.sign-arvo)
|
2019-09-29 07:44:31 +03:00
|
|
|
=/ =build-result:ford build-result.result.sign-arvo
|
|
|
|
?: ?=(%error -.build-result)
|
2019-11-16 14:25:30 +03:00
|
|
|
(thread-fail-not-running tid %find-thread-error message.build-result)
|
2019-09-29 07:44:31 +03:00
|
|
|
?. ?=([%path *] +.build-result)
|
2019-11-16 14:25:30 +03:00
|
|
|
(thread-fail-not-running tid %find-thread-strange ~)
|
2019-11-16 04:20:56 +03:00
|
|
|
=. starting.state
|
2019-11-16 14:25:30 +03:00
|
|
|
(~(jab by starting.state) yarn |=([=trying =vase] [%build vase]))
|
2019-09-29 07:44:31 +03:00
|
|
|
=/ =card
|
|
|
|
=/ =schematic:ford [%core rail.build-result]
|
2019-11-16 14:25:30 +03:00
|
|
|
[%pass /build/[tid] %arvo %f %build live=%.n schematic]
|
2019-09-26 22:00:11 +03:00
|
|
|
[[card ~] state]
|
|
|
|
::
|
|
|
|
++ handle-build
|
2019-11-16 14:25:30 +03:00
|
|
|
|= [=tid =sign-arvo]
|
2019-09-26 22:00:11 +03:00
|
|
|
^- (quip card ^state)
|
2019-11-16 14:25:30 +03:00
|
|
|
=/ =yarn (~(got by tid.state) tid)
|
2019-11-16 04:20:56 +03:00
|
|
|
=. starting.state
|
2019-11-16 14:25:30 +03:00
|
|
|
(~(jab by starting.state) yarn |=([=trying =vase] [%none vase]))
|
2019-09-26 22:00:11 +03:00
|
|
|
?> ?=([%f %made *] sign-arvo)
|
|
|
|
?: ?=(%incomplete -.result.sign-arvo)
|
2019-11-16 14:25:30 +03:00
|
|
|
(thread-fail-not-running tid %build-thread-incomplete tang.result.sign-arvo)
|
2019-09-26 22:00:11 +03:00
|
|
|
=/ =build-result:ford build-result.result.sign-arvo
|
|
|
|
?: ?=(%error -.build-result)
|
2019-11-16 14:25:30 +03:00
|
|
|
(thread-fail-not-running tid %build-thread-error message.build-result)
|
2019-09-26 22:00:11 +03:00
|
|
|
=/ =cage (result-to-cage:ford build-result)
|
|
|
|
?. ?=(%noun p.cage)
|
2019-11-16 14:25:30 +03:00
|
|
|
(thread-fail-not-running tid %build-thread-strange >p.cage< ~)
|
|
|
|
=/ maybe-thread (mule |.(!<(thread q.cage)))
|
|
|
|
?: ?=(%| -.maybe-thread)
|
|
|
|
(thread-fail-not-running tid %thread-not-thread ~)
|
|
|
|
(start-thread yarn p.maybe-thread)
|
|
|
|
::
|
|
|
|
++ start-thread
|
|
|
|
|= [=yarn =thread]
|
2019-09-26 22:00:11 +03:00
|
|
|
^- (quip card ^state)
|
2019-11-16 14:25:30 +03:00
|
|
|
=/ =vase vase:(~(got by starting.state) yarn)
|
|
|
|
?< (has-yarn running.state yarn)
|
|
|
|
=/ m (strand ,^vase)
|
|
|
|
=/ res (mule |.((thread vase)))
|
2019-11-16 04:20:56 +03:00
|
|
|
?: ?=(%| -.res)
|
2019-11-16 14:25:30 +03:00
|
|
|
(thread-fail-not-running (yarn-to-tid yarn) %false-start p.res)
|
2019-11-10 10:27:07 +03:00
|
|
|
=/ =eval-form:eval:m
|
2019-11-16 04:20:56 +03:00
|
|
|
(from-form:eval:m p.res)
|
2019-11-16 14:25:30 +03:00
|
|
|
=: starting.state (~(del by starting.state) yarn)
|
|
|
|
running.state (put-yarn running.state yarn eval-form)
|
2019-11-16 04:20:56 +03:00
|
|
|
==
|
2019-11-16 14:25:30 +03:00
|
|
|
(take-input yarn ~)
|
2019-09-26 07:12:58 +03:00
|
|
|
::
|
2019-11-16 14:25:30 +03:00
|
|
|
++ handle-stop-thread
|
|
|
|
|= [=tid nice=?]
|
2019-09-29 07:44:31 +03:00
|
|
|
^- (quip card ^state)
|
2019-11-16 14:25:30 +03:00
|
|
|
=/ =yarn (~(got by tid.state) tid)
|
|
|
|
?: (has-yarn running.state yarn)
|
2019-11-16 04:20:56 +03:00
|
|
|
?: nice
|
2019-11-16 14:25:30 +03:00
|
|
|
(thread-done yarn *vase)
|
|
|
|
(thread-fail yarn %cancelled ~)
|
|
|
|
?: (~(has by starting.state) yarn)
|
|
|
|
(thread-fail-not-running tid %stopped-before-started ~)
|
|
|
|
~& [%thread-not-started yarn]
|
2019-11-16 04:20:56 +03:00
|
|
|
`state
|
2019-09-29 07:44:31 +03:00
|
|
|
::
|
2019-09-26 07:12:58 +03:00
|
|
|
++ take-input
|
2019-11-16 14:25:30 +03:00
|
|
|
|= [=yarn input=(unit input:strand)]
|
2019-09-26 07:12:58 +03:00
|
|
|
^- (quip card ^state)
|
2019-11-16 14:25:30 +03:00
|
|
|
=/ m (strand ,vase)
|
|
|
|
?. (has-yarn running.state yarn)
|
|
|
|
%- (slog leaf+"spider got input for non-existent {<yarn>} 2" ~)
|
2019-10-01 06:53:02 +03:00
|
|
|
`state
|
2019-09-26 07:12:58 +03:00
|
|
|
=/ =eval-form:eval:m
|
2019-11-16 14:25:30 +03:00
|
|
|
thread-form:(need (get-yarn running.state yarn))
|
2019-09-26 07:12:58 +03:00
|
|
|
=| cards=(list card)
|
|
|
|
|- ^- (quip card ^state)
|
|
|
|
=^ r=[cards=(list card) =eval-result:eval:m] eval-form
|
|
|
|
=/ out
|
|
|
|
%- mule |.
|
2019-11-16 14:25:30 +03:00
|
|
|
(take:eval:m eval-form (convert-bowl yarn bowl) input)
|
2019-09-26 07:12:58 +03:00
|
|
|
?- -.out
|
|
|
|
%& p.out
|
|
|
|
%| [[~ [%fail %crash p.out]] eval-form]
|
|
|
|
==
|
2019-11-16 14:25:30 +03:00
|
|
|
=. running.state (put-yarn running.state yarn eval-form)
|
|
|
|
=/ =tid (yarn-to-tid yarn)
|
2019-09-26 07:12:58 +03:00
|
|
|
=. cards.r
|
|
|
|
%+ turn cards.r
|
|
|
|
|= =card
|
|
|
|
^- ^card
|
|
|
|
?+ card card
|
2019-11-16 14:25:30 +03:00
|
|
|
[%pass * *] [%pass [%thread tid p.card] q.card]
|
2019-11-07 09:19:32 +03:00
|
|
|
[%give %fact *]
|
2019-09-26 07:12:58 +03:00
|
|
|
?~ path.p.card
|
|
|
|
card
|
2019-11-16 14:25:30 +03:00
|
|
|
card(path.p `[%thread tid u.path.p.card])
|
2019-09-26 07:12:58 +03:00
|
|
|
::
|
2019-11-07 09:19:32 +03:00
|
|
|
[%give %kick *]
|
2019-09-26 07:12:58 +03:00
|
|
|
?~ path.p.card
|
|
|
|
card
|
2019-11-16 14:25:30 +03:00
|
|
|
card(path.p `[%thread tid u.path.p.card])
|
2019-09-26 07:12:58 +03:00
|
|
|
==
|
|
|
|
=. cards (weld cards cards.r)
|
|
|
|
=^ final-cards=(list card) state
|
|
|
|
?- -.eval-result.r
|
|
|
|
%next `state
|
2019-11-16 14:25:30 +03:00
|
|
|
%fail (thread-fail yarn err.eval-result.r)
|
|
|
|
%done (thread-done yarn value.eval-result.r)
|
2019-09-26 07:12:58 +03:00
|
|
|
==
|
|
|
|
[(weld cards final-cards) state]
|
|
|
|
::
|
2019-11-16 14:25:30 +03:00
|
|
|
++ thread-fail-not-running
|
|
|
|
|= [=tid =term =tang]
|
|
|
|
=/ =yarn (~(got by tid.state) tid)
|
|
|
|
:_ state(starting (~(del by starting.state) yarn))
|
|
|
|
%- welp :_ (thread-say-fail tid term tang)
|
|
|
|
=/ =trying trying:(~(got by starting.state) yarn)
|
2019-11-16 04:20:56 +03:00
|
|
|
?- trying
|
2019-11-16 14:25:30 +03:00
|
|
|
%find [%pass /find/[tid] %arvo %f %kill ~]~
|
|
|
|
%build [%pass /build/[tid] %arvo %f %kill ~]~
|
2019-11-16 04:20:56 +03:00
|
|
|
%none ~
|
|
|
|
==
|
|
|
|
::
|
2019-11-16 14:25:30 +03:00
|
|
|
++ thread-say-fail
|
|
|
|
|= [=tid =term =tang]
|
2019-11-16 04:20:56 +03:00
|
|
|
^- (list card)
|
2019-11-16 14:25:30 +03:00
|
|
|
:~ [%give %fact `/thread-result/[tid] %thread-fail !>([term tang])]
|
|
|
|
[%give %kick `/thread-result/[tid] ~]
|
2019-11-16 04:20:56 +03:00
|
|
|
==
|
|
|
|
::
|
2019-11-16 14:25:30 +03:00
|
|
|
++ thread-fail
|
|
|
|
|= [=yarn =term =tang]
|
2019-09-26 07:12:58 +03:00
|
|
|
^- (quip card ^state)
|
2019-11-16 14:25:30 +03:00
|
|
|
%- (slog leaf+"strand {<yarn>} failed" leaf+<term> tang)
|
|
|
|
=/ =tid (yarn-to-tid yarn)
|
|
|
|
=/ fail-cards (thread-say-fail tid term tang)
|
|
|
|
=^ cards state (thread-clean yarn)
|
2019-11-10 06:09:02 +03:00
|
|
|
[(weld fail-cards cards) state]
|
2019-09-26 07:12:58 +03:00
|
|
|
::
|
2019-11-16 14:25:30 +03:00
|
|
|
++ thread-done
|
|
|
|
|= [=yarn =vase]
|
2019-09-26 07:12:58 +03:00
|
|
|
^- (quip card ^state)
|
2019-11-16 14:25:30 +03:00
|
|
|
:: %- (slog leaf+"strand {<yarn>} finished" (sell vase) ~)
|
|
|
|
=/ =tid (yarn-to-tid yarn)
|
2019-11-10 06:09:02 +03:00
|
|
|
=/ done-cards=(list card)
|
2019-11-16 14:25:30 +03:00
|
|
|
:~ [%give %fact `/thread-result/[tid] %thread-done vase]
|
|
|
|
[%give %kick `/thread-result/[tid] ~]
|
2019-11-10 06:09:02 +03:00
|
|
|
==
|
2019-11-16 14:25:30 +03:00
|
|
|
=^ cards state (thread-clean yarn)
|
2019-11-10 06:09:02 +03:00
|
|
|
[(weld done-cards cards) state]
|
2019-10-01 06:53:02 +03:00
|
|
|
::
|
2019-11-16 14:25:30 +03:00
|
|
|
++ thread-clean
|
|
|
|
|= =yarn
|
2019-10-01 06:53:02 +03:00
|
|
|
^- (quip card ^state)
|
2019-11-16 14:25:30 +03:00
|
|
|
=/ children=(list ^yarn)
|
|
|
|
[yarn (get-yarn-children running.state yarn)]
|
2019-11-10 10:27:07 +03:00
|
|
|
|- ^- (quip card ^state)
|
|
|
|
?~ children
|
|
|
|
`state
|
|
|
|
=^ cards-children state $(children t.children)
|
|
|
|
=^ cards-our state
|
2019-11-16 14:25:30 +03:00
|
|
|
=/ =^yarn i.children
|
|
|
|
=/ =tid (yarn-to-tid yarn)
|
|
|
|
=: running.state (del-yarn running.state yarn)
|
|
|
|
tid.state (~(del by tid.state) tid)
|
2019-10-01 06:53:02 +03:00
|
|
|
==
|
2019-11-10 10:27:07 +03:00
|
|
|
:_ state
|
|
|
|
%+ murn ~(tap by wex.bowl)
|
|
|
|
|= [[=wire =ship =term] [acked=? =path]]
|
|
|
|
^- (unit card)
|
2019-11-16 14:25:30 +03:00
|
|
|
?. ?& ?=([%thread @ *] wire)
|
|
|
|
=(tid i.t.wire)
|
2019-11-10 10:27:07 +03:00
|
|
|
==
|
|
|
|
~
|
|
|
|
`[%pass wire %agent [ship term] %leave ~]
|
|
|
|
[(welp cards-children cards-our) state]
|
|
|
|
::
|
|
|
|
++ convert-bowl
|
2019-11-19 07:36:21 +03:00
|
|
|
|= [=yarn =bowl:gall]
|
2019-11-10 10:27:07 +03:00
|
|
|
^- bowl:spider
|
|
|
|
:* our.bowl
|
|
|
|
src.bowl
|
2019-11-16 14:25:30 +03:00
|
|
|
(yarn-to-tid yarn)
|
|
|
|
(yarn-to-parent yarn)
|
2019-11-10 10:27:07 +03:00
|
|
|
wex.bowl
|
|
|
|
sup.bowl
|
|
|
|
eny.bowl
|
|
|
|
now.bowl
|
|
|
|
byk.bowl
|
|
|
|
==
|
|
|
|
::
|
2019-11-16 14:25:30 +03:00
|
|
|
++ yarn-to-tid
|
|
|
|
|= =yarn
|
|
|
|
^- tid
|
|
|
|
=/ nary (flop yarn)
|
|
|
|
?> ?=([@ *] nary)
|
|
|
|
i.nary
|
|
|
|
::
|
|
|
|
++ yarn-to-parent
|
|
|
|
|= =yarn
|
|
|
|
^- (unit tid)
|
|
|
|
=/ nary (flop yarn)
|
|
|
|
?> ?=([@ *] nary)
|
|
|
|
?~ t.nary
|
2019-10-01 06:53:02 +03:00
|
|
|
~
|
2019-11-16 14:25:30 +03:00
|
|
|
`i.t.nary
|
2019-11-10 10:27:07 +03:00
|
|
|
::
|
|
|
|
++ clean-state
|
|
|
|
!> ^- clean-slate
|
2019-11-16 14:25:30 +03:00
|
|
|
state(running (turn (tap-yarn running.state) head))
|
2019-09-26 07:12:58 +03:00
|
|
|
--
|