ames: refactor %stir, %rest stale/wrong timers

This commit is contained in:
Joe Bryan 2022-08-22 18:25:49 -04:00
parent a04d564269
commit 9439841ce8

View File

@ -1475,44 +1475,40 @@
:: ::
++ on-stir ++ on-stir
|= arg=@t |= arg=@t
=/ states=(list [ship peer-state]) ^+ event-core
%+ murn ~(tap by peers.ames-state) =/ want=(set [@da ^duct])
|= [=ship =ship-state] %- ~(rep by peers.ames-state)
^- (unit [^ship peer-state]) |= [[who=ship s=ship-state] acc=(set [@da ^duct])]
?. ?=(%known -.ship-state) ?. ?=(%known -.s) acc
~ %- ~(rep by snd.+.s)
`[ship +.ship-state] |= [[b=bone m=message-pump-state] acc=_acc]
=/ snds=(list (list [ship bone message-pump-state])) =* tim next-wake.packet-pump-state.m
%+ turn states ?~ tim acc
|= [=ship peer-state] %- ~(put in acc)
%+ turn ~(tap by snd) [u.tim `^duct`~[ames+(make-pump-timer-wire who b) /ames]]
|= [=bone =message-pump-state] ::
[ship bone message-pump-state] =/ have
=/ next-wakes %- ~(gas in *(set [@da ^duct]))
%+ turn `(list [ship bone message-pump-state])`(zing snds) =/ tim
|= [=ship =bone message-pump-state]
[ship bone next-wake.packet-pump-state]
=/ next-real-wakes=(list [=ship =bone =@da])
%+ murn next-wakes
|= [=ship =bone tym=(unit @da)]
^- (unit [^ship ^bone @da])
?~(tym ~ `[ship bone u.tym])
=/ timers
%- silt
;; (list [@da ^duct]) ;; (list [@da ^duct])
=< q.q %- need %- need =< q.q %- need %- need
(rof ~ %bx [[our %$ da+now] /debug/timers]) (rof ~ %bx [[our %$ da+now] /debug/timers])
=/ to-stir (skim tim |=([@da hen=^duct] ?=([[%ames %pump *] *] hen)))
%+ skip next-real-wakes ::
|= [=ship =bone =@da] :: %wait on missing flows
(~(has in timers) [da `^duct`~[a+(make-pump-timer-wire ship bone) /ames]]) ::
~& [%stirring to-stir] =. event-core
|- ^+ event-core %- ~(rep in (~(dif in want) have))
?~ to-stir |= [[wen=@da hen=^duct] this=_event-core]
event-core ?> ?=([^ *] hen)
=/ =wire (make-pump-timer-wire [ship bone]:i.to-stir) (emit:this ~[/ames] %pass t.i.hen %b %wait wen)
=. event-core (emit duct %pass wire %b %wait da.i.to-stir) ::
$(to-stir t.to-stir) :: %rest on this bullshit
::
%- ~(rep in (~(dif in have) want))
|= [[wen=@da hen=^duct] this=_event-core]
?> ?=([^ *] hen)
(emit:this t.hen %pass t.i.hen %b %rest wen)
:: +on-crud: handle event failure; print to dill :: +on-crud: handle event failure; print to dill
:: ::
++ on-crud ++ on-crud