2019-11-10 10:27:07 +03:00
|
|
|
/- *aquarium, spider
|
2019-11-16 14:25:30 +03:00
|
|
|
/+ libstrand=strand, *strandio, util=ph-util
|
|
|
|
=, strand=strand:libstrand
|
2019-09-29 07:44:31 +03:00
|
|
|
|%
|
|
|
|
++ send-events
|
|
|
|
|= events=(list aqua-event)
|
2019-11-16 14:25:30 +03:00
|
|
|
=/ m (strand ,~)
|
2019-09-29 07:44:31 +03:00
|
|
|
^- form:m
|
|
|
|
(poke-our %aqua %aqua-events !>(events))
|
|
|
|
::
|
2020-11-30 11:02:51 +03:00
|
|
|
++ send-azimuth-action
|
|
|
|
|= =azimuth-action
|
|
|
|
=/ m (strand ,~)
|
|
|
|
^- form:m
|
|
|
|
(poke-our %aqua %azimuth-action !>(azimuth-action))
|
|
|
|
::
|
2019-09-29 07:44:31 +03:00
|
|
|
++ take-unix-effect
|
2019-11-16 14:25:30 +03:00
|
|
|
=/ m (strand ,[ship unix-effect])
|
2019-09-29 07:44:31 +03:00
|
|
|
^- form:m
|
2019-12-04 10:53:42 +03:00
|
|
|
;< [=path =cage] bind:m (take-fact-prefix /effect)
|
2019-09-29 07:44:31 +03:00
|
|
|
?> ?=(%aqua-effect p.cage)
|
|
|
|
(pure:m !<([aqua-effect] q.cage))
|
|
|
|
::
|
|
|
|
++ start-simple
|
2019-10-02 05:50:25 +03:00
|
|
|
(start-test %aqua-ames %aqua-behn %aqua-dill %aqua-eyre ~)
|
|
|
|
::
|
|
|
|
++ start-azimuth
|
2021-06-18 08:53:07 +03:00
|
|
|
=/ m (strand ,~)
|
2019-11-15 00:31:44 +03:00
|
|
|
^- form:m
|
2021-06-18 08:53:07 +03:00
|
|
|
;<(~ bind:m start-simple init)
|
2019-11-15 00:31:44 +03:00
|
|
|
::
|
2021-06-18 08:53:07 +03:00
|
|
|
++ end
|
|
|
|
(end-test %aqua-ames %aqua-behn %aqua-dill %aqua-eyre ~)
|
2019-10-02 05:50:25 +03:00
|
|
|
::
|
|
|
|
++ start-test
|
2019-11-16 14:25:30 +03:00
|
|
|
|= vane-threads=(list term)
|
|
|
|
=/ m (strand ,~)
|
2019-09-29 07:44:31 +03:00
|
|
|
^- form:m
|
2019-10-02 01:06:12 +03:00
|
|
|
~& > "starting"
|
2020-11-30 11:02:51 +03:00
|
|
|
;< tids=(map term tid:spider) bind:m (start-threads vane-threads)
|
2019-12-04 10:53:42 +03:00
|
|
|
;< ~ bind:m (watch-our /effect %aqua /effect)
|
2019-10-02 01:06:12 +03:00
|
|
|
:: Get our very own event with no mistakes in it... yet.
|
|
|
|
::
|
2019-11-16 14:25:30 +03:00
|
|
|
:: We want to wait for the vane threads to actually start and get
|
|
|
|
:: their subscriptions started. Other ways to do this are delaying
|
|
|
|
:: the ack from spider until the build is finished (does that
|
|
|
|
:: guarantee the subscriptions have started?) or subscribe to the
|
|
|
|
:: threads themselves for a notification when they're done. This is
|
|
|
|
:: probably the best option because the thread can delay until it
|
|
|
|
:: gets a positive ack on the subscription.
|
2019-10-01 06:53:02 +03:00
|
|
|
::
|
2020-04-24 05:07:33 +03:00
|
|
|
:: Threads might not get built until a %writ is dripped back to
|
|
|
|
:: spider. Drips are at +(now), so we sleep until two clicks in the
|
|
|
|
:: future.
|
|
|
|
::
|
|
|
|
;< ~ bind:m (sleep `@dr`2)
|
2019-09-29 07:44:31 +03:00
|
|
|
(pure:m ~)
|
|
|
|
::
|
2019-10-02 05:50:25 +03:00
|
|
|
++ end-test
|
2019-11-16 14:25:30 +03:00
|
|
|
|= vane-threads=(list term)
|
|
|
|
=/ m (strand ,~)
|
2019-09-29 07:44:31 +03:00
|
|
|
^- form:m
|
2019-10-02 01:06:12 +03:00
|
|
|
~& > "done"
|
2019-11-16 14:25:30 +03:00
|
|
|
;< ~ bind:m (stop-threads vane-threads)
|
2019-12-04 10:53:42 +03:00
|
|
|
;< ~ bind:m (leave-our /effect %aqua)
|
2019-09-29 07:44:31 +03:00
|
|
|
(pure:m ~)
|
|
|
|
::
|
2019-11-16 14:25:30 +03:00
|
|
|
++ start-threads
|
|
|
|
|= threads=(list term)
|
2020-11-30 11:02:51 +03:00
|
|
|
=/ m (strand ,(map term tid:spider))
|
2019-09-29 07:44:31 +03:00
|
|
|
^- form:m
|
2019-11-10 10:27:07 +03:00
|
|
|
;< =bowl:spider bind:m get-bowl
|
2020-11-30 11:02:51 +03:00
|
|
|
=| tids=(map term tid:spider)
|
2019-09-29 07:44:31 +03:00
|
|
|
|- ^- form:m
|
|
|
|
=* loop $
|
2019-11-16 14:25:30 +03:00
|
|
|
?~ threads
|
2020-11-30 11:02:51 +03:00
|
|
|
(pure:m tids)
|
|
|
|
=/ tid
|
|
|
|
%+ scot %ta
|
|
|
|
(cat 3 (cat 3 'strand_' i.threads) (scot %uv (sham i.threads eny.bowl)))
|
2021-07-19 15:17:55 +03:00
|
|
|
=/ poke-vase !>([`tid.bowl ~ byk.bowl i.threads *vase])
|
2019-09-29 07:44:31 +03:00
|
|
|
;< ~ bind:m (poke-our %spider %spider-start poke-vase)
|
2020-11-30 11:02:51 +03:00
|
|
|
loop(threads t.threads, tids (~(put by tids) i.threads tid))
|
2019-09-29 07:44:31 +03:00
|
|
|
::
|
2019-11-16 14:25:30 +03:00
|
|
|
++ stop-threads
|
|
|
|
|= threads=(list term)
|
|
|
|
=/ m (strand ,~)
|
2019-09-29 07:44:31 +03:00
|
|
|
^- form:m
|
2019-11-10 10:27:07 +03:00
|
|
|
(pure:m ~)
|
2019-09-29 07:44:31 +03:00
|
|
|
::
|
2020-11-30 11:02:51 +03:00
|
|
|
::
|
2021-06-18 08:53:07 +03:00
|
|
|
++ init
|
2020-11-30 11:02:51 +03:00
|
|
|
=/ m (strand ,~)
|
|
|
|
^- form:m
|
|
|
|
(send-azimuth-action %init-azimuth ~)
|
|
|
|
::
|
2021-06-18 08:53:07 +03:00
|
|
|
++ spawn
|
2020-11-30 11:02:51 +03:00
|
|
|
|= =ship
|
|
|
|
~& > "spawning {<ship>}"
|
|
|
|
=/ m (strand ,~)
|
|
|
|
^- form:m
|
|
|
|
(send-azimuth-action %spawn ship)
|
|
|
|
::
|
2021-06-18 08:53:07 +03:00
|
|
|
++ breach
|
2020-11-30 11:02:51 +03:00
|
|
|
|= =ship
|
|
|
|
~& > "breaching {<ship>}"
|
|
|
|
=/ m (strand ,~)
|
|
|
|
^- form:m
|
|
|
|
(send-azimuth-action %breach ship)
|
|
|
|
::
|
2019-11-15 03:39:28 +03:00
|
|
|
:: who: breachee
|
|
|
|
:: her: wait until hears about breach
|
|
|
|
::
|
2019-10-02 06:25:19 +03:00
|
|
|
++ breach-and-hear
|
2020-11-30 11:02:51 +03:00
|
|
|
|= [who=ship her=ship]
|
2021-06-18 08:53:07 +03:00
|
|
|
~& > "breaching {<who>} for {<her>}"
|
2020-11-30 11:02:51 +03:00
|
|
|
=/ m (strand ,~)
|
|
|
|
;< =bowl:spider bind:m get-bowl
|
|
|
|
=/ aqua-pax
|
|
|
|
:- %i
|
|
|
|
/(scot %p her)/j/(scot %p her)/rift/(scot %da now.bowl)/(scot %p who)/noun
|
|
|
|
=/ old-rut ;;((unit @) (scry-aqua:util noun our.bowl now.bowl aqua-pax))
|
|
|
|
=/ new-rut
|
|
|
|
?~ old-rut
|
|
|
|
1
|
|
|
|
+(+.old-rut)
|
|
|
|
;< ~ bind:m (send-azimuth-action %breach who)
|
|
|
|
|- ^- form:m
|
|
|
|
=* loop $
|
|
|
|
;< ~ bind:m (sleep ~s1)
|
|
|
|
;< =bowl:spider bind:m get-bowl
|
|
|
|
=/ aqua-pax
|
|
|
|
:- %i
|
|
|
|
/(scot %p her)/j/(scot %p her)/rift/(scot %da now.bowl)/(scot %p who)/noun
|
|
|
|
=/ rut (scry-aqua:util noun our.bowl now.bowl aqua-pax)
|
|
|
|
?: =([~ new-rut] rut)
|
|
|
|
(pure:m ~)
|
|
|
|
loop
|
|
|
|
::
|
|
|
|
++ init-ship
|
2021-06-18 08:53:07 +03:00
|
|
|
|= [=ship fake=?]
|
2019-11-16 14:25:30 +03:00
|
|
|
=/ m (strand ,~)
|
2019-09-29 07:44:31 +03:00
|
|
|
^- form:m
|
2019-10-02 01:06:12 +03:00
|
|
|
~& > "starting {<ship>}"
|
2021-06-18 08:53:07 +03:00
|
|
|
;< ~ bind:m (send-events (init:util ship fake))
|
2019-09-29 07:44:31 +03:00
|
|
|
(check-ship-booted ship)
|
|
|
|
::
|
|
|
|
++ check-ship-booted
|
|
|
|
|= =ship
|
2019-11-16 14:25:30 +03:00
|
|
|
=/ m (strand ,~)
|
2019-09-29 07:44:31 +03:00
|
|
|
^- form:m
|
|
|
|
=* loop $
|
|
|
|
;< [her=^ship =unix-effect] bind:m take-unix-effect
|
|
|
|
=/ f |=(=tape (is-dojo-output:util ship her unix-effect tape))
|
|
|
|
:: This is a pretty bad heuristic, but in general galaxies will
|
|
|
|
:: hit the first of these cases, and other ships will hit the
|
|
|
|
:: second.
|
|
|
|
::
|
2020-04-24 05:07:33 +03:00
|
|
|
?: ?| (f ":dojo>")
|
2019-09-29 07:44:31 +03:00
|
|
|
(f "is your neighbor")
|
|
|
|
==
|
|
|
|
(pure:m ~)
|
|
|
|
loop
|
|
|
|
::
|
|
|
|
++ dojo
|
|
|
|
|= [=ship =tape]
|
2019-11-16 14:25:30 +03:00
|
|
|
=/ m (strand ,~)
|
2019-09-29 07:44:31 +03:00
|
|
|
^- form:m
|
2019-10-02 01:06:12 +03:00
|
|
|
~& > "dojo: {tape}"
|
2019-09-29 07:44:31 +03:00
|
|
|
(send-events (dojo:util ship tape))
|
|
|
|
::
|
|
|
|
++ wait-for-output
|
|
|
|
|= [=ship =tape]
|
2019-11-16 14:25:30 +03:00
|
|
|
=/ m (strand ,~)
|
2019-09-29 07:44:31 +03:00
|
|
|
^- form:m
|
2019-10-02 01:06:12 +03:00
|
|
|
~& > "waiting for output: {tape}"
|
|
|
|
|- ^- form:m
|
2019-09-29 07:44:31 +03:00
|
|
|
=* loop $
|
|
|
|
;< [her=^ship =unix-effect] bind:m take-unix-effect
|
|
|
|
?: (is-dojo-output:util ship her unix-effect tape)
|
|
|
|
(pure:m ~)
|
|
|
|
loop
|
2019-10-02 01:06:12 +03:00
|
|
|
::
|
|
|
|
:: Send "|hi" from one ship to another
|
|
|
|
::
|
|
|
|
++ send-hi
|
|
|
|
|= [from=@p to=@p]
|
2019-11-16 14:25:30 +03:00
|
|
|
=/ m (strand ,~)
|
2019-10-02 01:06:12 +03:00
|
|
|
^- form:m
|
|
|
|
;< ~ bind:m (dojo from "|hi {(scow %p to)}")
|
|
|
|
(wait-for-output from "hi {(scow %p to)} successful")
|
|
|
|
::
|
2019-10-02 06:25:19 +03:00
|
|
|
:: Send "|hi" and wait for "not responding" message
|
|
|
|
::
|
|
|
|
++ send-hi-not-responding
|
|
|
|
|= [from=@p to=@p]
|
2021-06-18 08:53:07 +03:00
|
|
|
~& > 'sending hi not responding'
|
2019-11-16 14:25:30 +03:00
|
|
|
=/ m (strand ,~)
|
2019-10-02 06:25:19 +03:00
|
|
|
;< ~ bind:m (dojo from "|hi {(scow %p to)}")
|
|
|
|
(wait-for-output from "{(scow %p to)} not responding still trying")
|
|
|
|
::
|
2019-10-02 01:06:12 +03:00
|
|
|
:: Mount a desk.
|
|
|
|
::
|
|
|
|
++ mount
|
|
|
|
|= [=ship =desk]
|
2019-11-16 14:25:30 +03:00
|
|
|
=/ m (strand ,~)
|
2019-10-02 01:06:12 +03:00
|
|
|
^- form:m
|
|
|
|
;< ~ bind:m (dojo ship "|mount /={(trip desk)}=")
|
|
|
|
|- ^- form:m
|
|
|
|
=* loop $
|
|
|
|
;< [her=^ship =unix-effect] bind:m take-unix-effect
|
|
|
|
?: (is-ergo:util ship her unix-effect)
|
|
|
|
(pure:m ~)
|
|
|
|
loop
|
|
|
|
::
|
|
|
|
:: Modify /sur/aquarium/hoon on the given ship
|
|
|
|
::
|
|
|
|
++ touch-file
|
2019-11-15 23:46:11 +03:00
|
|
|
|= [her=ship =desk extra=@t]
|
2019-11-16 14:25:30 +03:00
|
|
|
=/ m (strand ,@t)
|
2019-10-02 01:06:12 +03:00
|
|
|
^- form:m
|
2020-04-25 03:44:29 +03:00
|
|
|
(touch her desk /sur/aquarium/hoon extra)
|
|
|
|
::
|
|
|
|
:: Modify path on the given ship
|
|
|
|
::
|
|
|
|
++ touch
|
|
|
|
|= [her=ship =desk pax=path extra=@t]
|
|
|
|
=/ m (strand ,@t)
|
|
|
|
^- form:m
|
2019-10-02 01:06:12 +03:00
|
|
|
~& > "touching file on {<her>}/{<desk>}"
|
|
|
|
;< ~ bind:m (mount her desk)
|
|
|
|
;< our=@p bind:m get-our
|
|
|
|
;< now=@da bind:m get-time
|
|
|
|
=/ aqua-pax
|
|
|
|
;: weld
|
|
|
|
/i/(scot %p her)/cx/(scot %p her)/[desk]/(scot %da now)
|
|
|
|
pax
|
|
|
|
/noun
|
|
|
|
==
|
|
|
|
=/ warped
|
|
|
|
%^ cat 3 '=> . '
|
2019-11-15 23:46:11 +03:00
|
|
|
%^ cat 3 extra
|
2019-10-02 01:06:12 +03:00
|
|
|
(need (scry-aqua:util (unit @) our now aqua-pax))
|
2020-05-22 09:05:42 +03:00
|
|
|
;< ~ bind:m (send-events (insert-files:util her desk [pax warped] ~))
|
2019-10-02 01:06:12 +03:00
|
|
|
(pure:m warped)
|
|
|
|
::
|
|
|
|
:: Check /sur/aquarium/hoon on the given has the given contents.
|
|
|
|
::
|
|
|
|
++ check-file-touched
|
|
|
|
|= [=ship =desk warped=@t]
|
2019-11-16 14:25:30 +03:00
|
|
|
=/ m (strand ,~)
|
2020-04-25 03:44:29 +03:00
|
|
|
(check-touched ship desk /sur/aquarium/hoon warped)
|
|
|
|
::
|
|
|
|
:: Check path on the given desk has the given contents.
|
|
|
|
::
|
|
|
|
++ check-touched
|
|
|
|
|= [=ship =desk pax=path warped=@t]
|
|
|
|
=/ m (strand ,~)
|
2019-10-02 01:06:12 +03:00
|
|
|
~& > "checking file touched on {<ship>}/{<desk>}"
|
|
|
|
;< ~ bind:m (mount ship desk)
|
|
|
|
^- form:m
|
|
|
|
|- ^- form:m
|
|
|
|
=* loop $
|
|
|
|
;< [her=^ship =unix-effect] bind:m take-unix-effect
|
|
|
|
;< our=@p bind:m get-our
|
|
|
|
;< now=@da bind:m get-time
|
|
|
|
:: %ergo is no longer sufficient because .^ is pinned to beginning of
|
|
|
|
:: the event. So we hope somebody sets a timer for something.
|
|
|
|
::
|
|
|
|
?. &(=(ship her) ?=(?(%init %ergo %doze) -.q.unix-effect))
|
|
|
|
loop
|
|
|
|
=/ aqua-pax
|
|
|
|
;: weld
|
|
|
|
/i/(scot %p ship)/cx/(scot %p ship)/[desk]/(scot %da now)
|
|
|
|
pax
|
|
|
|
/noun
|
|
|
|
==
|
|
|
|
?: =(warped (need (scry-aqua:util (unit @) our now aqua-pax)))
|
|
|
|
(pure:m ~)
|
|
|
|
loop
|
2020-12-01 00:04:54 +03:00
|
|
|
::
|
|
|
|
:: Turns poke into a dojo command
|
|
|
|
::
|
|
|
|
++ poke-app
|
|
|
|
|= [=ship app=term =mark data=*]
|
|
|
|
=/ m (strand ,~)
|
|
|
|
^- form:m
|
|
|
|
=/ command=tape ":{(trip app)} &{(trip mark)} {<data>}"
|
|
|
|
(send-events (dojo:util ship command))
|
|
|
|
::
|
|
|
|
++ dojo-thread
|
|
|
|
|= [=ship ted=term =mark data=*]
|
|
|
|
=/ m (strand ,~)
|
|
|
|
^- form:m
|
|
|
|
=/ command=tape "-{(trip ted)} &{(trip mark)} {<data>}"
|
|
|
|
(send-events (dojo:util ship command))
|
2019-09-29 07:44:31 +03:00
|
|
|
--
|