ph: add and modify some ph helper functions; adds new thread for booting/breaching in the new paradigm, as well as a helper thread for just starting drivers in case you want to manipulate aqua manually

This commit is contained in:
Isaac Visintainer 2020-11-30 00:02:51 -08:00
parent e03a18bad3
commit 5217a5c00e
4 changed files with 104 additions and 5 deletions

View File

@ -8,6 +8,12 @@
^- form:m
(poke-our %aqua %aqua-events !>(events))
::
++ send-azimuth-action
|= =azimuth-action
=/ m (strand ,~)
^- form:m
(poke-our %aqua %azimuth-action !>(azimuth-action))
::
++ take-unix-effect
=/ m (strand ,[ship unix-effect])
^- form:m
@ -34,7 +40,7 @@
=/ m (strand ,~)
^- form:m
~& > "starting"
;< ~ bind:m (start-threads vane-threads)
;< tids=(map term tid:spider) bind:m (start-threads vane-threads)
;< ~ bind:m (watch-our /effect %aqua /effect)
:: Get our very own event with no mistakes in it... yet.
::
@ -64,16 +70,20 @@
::
++ start-threads
|= threads=(list term)
=/ m (strand ,~)
=/ m (strand ,(map term tid:spider))
^- form:m
;< =bowl:spider bind:m get-bowl
=| tids=(map term tid:spider)
|- ^- form:m
=* loop $
?~ threads
(pure:m ~)
(pure:m tids)
=/ tid
%+ scot %ta
(cat 3 (cat 3 'strand_' i.threads) (scot %uv (sham i.threads eny.bowl)))
=/ poke-vase !>([`tid.bowl ~ i.threads *vase])
;< ~ bind:m (poke-our %spider %spider-start poke-vase)
loop(threads t.threads)
loop(threads t.threads, tids (~(put by tids) i.threads tid))
::
++ stop-threads
|= threads=(list term)
@ -81,6 +91,29 @@
^- form:m
(pure:m ~)
::
:: XX +spawn-aqua and +breach-aqua mean do these actions using aqua's internal
:: azimuth management system, eventually these should just replace +spawn
:: +breach
::
++ init-azimuth
=/ m (strand ,~)
^- form:m
(send-azimuth-action %init-azimuth ~)
::
++ spawn-aqua
|= =ship
~& > "spawning {<ship>}"
=/ m (strand ,~)
^- form:m
(send-azimuth-action %spawn ship)
::
++ breach-aqua
|= =ship
~& > "breaching {<ship>}"
=/ m (strand ,~)
^- form:m
(send-azimuth-action %breach ship)
::
++ spawn
|= [=tid:spider =ship]
~& > "spawning {<ship>}"
@ -127,6 +160,39 @@
(pure:m ~)
loop
::
++ breach-and-hear-aqua
|= [who=ship her=ship]
=/ 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
|= =ship
=/ m (strand ,~)
^- form:m
~& > "starting {<ship>}"
;< ~ bind:m (send-events (init:util ship `*dawn-event:able:jael))
(check-ship-booted ship)
::
++ real-ship
|= [=tid:spider =ship]
~& > "booting real {<ship>}"

View File

@ -654,7 +654,8 @@
=/ m (strand ,tid:spider)
^- form:m
;< =bowl:spider bind:m get-bowl
=/ tid (scot %ta (cat 3 'strand_' (scot %uv (sham file eny.bowl))))
=/ tid
(scot %ta (cat 3 (cat 3 'strand_' file) (scot %uv (sham file eny.bowl))))
=/ poke-vase !>([`tid.bowl `tid file *vase])
;< ~ bind:m (poke-our %spider %spider-start poke-vase)
;< ~ bind:m (sleep ~s0) :: wait for thread to start

View File

@ -0,0 +1,19 @@
/- spider
/+ *ph-io, *ph-util
=, strand=strand:spider
^- thread:spider
|= vase
=/ m (strand ,vase)
;< =bowl:spider bind:m get-bowl
;< ~ bind:m start-simple
;< ~ bind:m init-azimuth
;< ~ bind:m (spawn-aqua ~bud)
;< ~ bind:m (spawn-aqua ~dev)
;< ~ bind:m (init-ship ~bud)
;< ~ bind:m (init-ship ~dev)
;< ~ bind:m (send-hi ~bud ~dev)
;< ~ bind:m (breach-and-hear-aqua ~dev ~bud)
;< ~ bind:m (send-hi-not-responding ~bud ~dev)
;< ~ bind:m (init-ship ~dev)
;< ~ bind:m (wait-for-output ~bud "hi ~dev successful")
(pure:m *vase)

View File

@ -0,0 +1,13 @@
/- spider
/+ *ph-io, *ph-util
=, strand=strand:spider
^- thread:spider
|= vase
=/ m (strand ,vase)
;< =bowl:spider bind:m get-bowl
;< ~ bind:m start-simple
|-
=* loop $
~& >> %looping
;< ~ bind:m (sleep ~s5)
loop