mirror of
https://github.com/urbit/shrub.git
synced 2024-12-24 11:24:21 +03:00
ames: start drainage timer if regressed from adult
This accounts for a possible race condition where ames expects a response, but regresses into the larval state. Upon receiving the $sign on +take, we would remain stuck as a larva. Now we check that we have enough information to re-evolve and then start a /larval timer to begin draining the queue.
This commit is contained in:
parent
5d6b2d8997
commit
2553573be0
@ -1,3 +1,3 @@
|
|||||||
version https://git-lfs.github.com/spec/v1
|
version https://git-lfs.github.com/spec/v1
|
||||||
oid sha256:655bac06453b7d26ed0549576577dae1adc0fff3fefe202065cca752ff74e4e2
|
oid sha256:afe650a1583104e57bc83d7a0804405661b2e7a53e0673694ad53522b8894d79
|
||||||
size 9640752
|
size 9526886
|
||||||
|
@ -784,6 +784,13 @@
|
|||||||
|= [now=@da eny=@ rof=roof]
|
|= [now=@da eny=@ rof=roof]
|
||||||
=* larval-gate .
|
=* larval-gate .
|
||||||
=* adult-core (adult-gate +<)
|
=* adult-core (adult-gate +<)
|
||||||
|
=< |%
|
||||||
|
++ call ^call
|
||||||
|
++ load ^load
|
||||||
|
++ scry ^scry
|
||||||
|
++ stay ^stay
|
||||||
|
++ take ^take
|
||||||
|
--
|
||||||
|%
|
|%
|
||||||
:: +call: handle request $task
|
:: +call: handle request $task
|
||||||
::
|
::
|
||||||
@ -796,17 +803,8 @@
|
|||||||
?^ dud
|
?^ dud
|
||||||
~|(%ames-larval-call-dud (mean tang.u.dud))
|
~|(%ames-larval-call-dud (mean tang.u.dud))
|
||||||
::
|
::
|
||||||
=/ update-ready=?
|
?: &(?=(^ cached-state) ?=(~ queued-events))
|
||||||
?& ?=(^ cached-state)
|
(molt ~)
|
||||||
?=(~ queued-events)
|
|
||||||
==
|
|
||||||
?: update-ready
|
|
||||||
=. ames-state.adult-gate
|
|
||||||
?> ?=(^ cached-state)
|
|
||||||
(state-5-to-6:load:adult-core +.u.cached-state)
|
|
||||||
=. cached-state ~
|
|
||||||
~> %slog.1^leaf/"ames: metamorphosis reload"
|
|
||||||
[~ adult-gate]
|
|
||||||
:: %born: set .unix-duct and start draining .queued-events
|
:: %born: set .unix-duct and start draining .queued-events
|
||||||
::
|
::
|
||||||
?: ?=(%born -.task)
|
?: ?=(%born -.task)
|
||||||
@ -836,11 +834,17 @@
|
|||||||
~|(%ames-larval-take-dud (mean tang.u.dud))
|
~|(%ames-larval-take-dud (mean tang.u.dud))
|
||||||
:: enqueue event if not a larval drainage timer
|
:: enqueue event if not a larval drainage timer
|
||||||
::
|
::
|
||||||
|
=? queued-events !=(/larva wire)
|
||||||
|
(~(put to queued-events) %take wire duct sign)
|
||||||
|
:: start drainage timer if have regressed from adult ames
|
||||||
|
::
|
||||||
|
?: ?& !=(/larva wire)
|
||||||
|
?=(^ cached-state)
|
||||||
|
==
|
||||||
|
[[duct %pass /larva %b %wait now]~ larval-gate]
|
||||||
:: XX what to do with errors?
|
:: XX what to do with errors?
|
||||||
::
|
::
|
||||||
?. =(/larva wire)
|
?. =(/larva wire) [~ larval-gate]
|
||||||
=. queued-events (~(put to queued-events) %take wire duct sign)
|
|
||||||
[~ larval-gate]
|
|
||||||
:: larval event drainage timer; pop and process a queued event
|
:: larval event drainage timer; pop and process a queued event
|
||||||
::
|
::
|
||||||
?. ?=([%behn %wake *] sign)
|
?. ?=([%behn %wake *] sign)
|
||||||
@ -879,20 +883,10 @@
|
|||||||
%call (call:adult-core [duct ~ wrapped-task]:+.first-event)
|
%call (call:adult-core [duct ~ wrapped-task]:+.first-event)
|
||||||
%take (take:adult-core [wire duct ~ sign]:+.first-event)
|
%take (take:adult-core [wire duct ~ sign]:+.first-event)
|
||||||
==
|
==
|
||||||
=/ update-ready=?
|
|
||||||
?& ?=(^ cached-state)
|
|
||||||
?=(~ queued-events)
|
|
||||||
==
|
|
||||||
?: update-ready
|
|
||||||
=. ames-state.adult-gate
|
|
||||||
?> ?=(^ cached-state)
|
|
||||||
(state-5-to-6:load:adult-core +.u.cached-state)
|
|
||||||
=. cached-state ~
|
|
||||||
~> %slog.1^leaf/"ames: metamorphosis reload"
|
|
||||||
[moves adult-gate]
|
|
||||||
:: .queued-events has been cleared; metamorphose
|
:: .queued-events has been cleared; metamorphose
|
||||||
::
|
::
|
||||||
?~ queued-events
|
?~ queued-events
|
||||||
|
?: ?=(^ cached-state) (molt moves)
|
||||||
~> %slog.0^leaf/"ames: metamorphosis"
|
~> %slog.0^leaf/"ames: metamorphosis"
|
||||||
[moves adult-gate]
|
[moves adult-gate]
|
||||||
:: set timer to drain next event
|
:: set timer to drain next event
|
||||||
@ -952,6 +946,17 @@
|
|||||||
=. adult-gate (load:adult-core %6 state.old)
|
=. adult-gate (load:adult-core %6 state.old)
|
||||||
larval-gate
|
larval-gate
|
||||||
==
|
==
|
||||||
|
:: +molt: re-evolve to adult-ames
|
||||||
|
::
|
||||||
|
++ molt
|
||||||
|
|= moves=(list move)
|
||||||
|
^- (quip move _adult-gate)
|
||||||
|
=. ames-state.adult-gate
|
||||||
|
?> ?=(^ cached-state)
|
||||||
|
(state-5-to-6:load:adult-core +.u.cached-state)
|
||||||
|
=. cached-state ~
|
||||||
|
~> %slog.1^leaf/"ames: metamorphosis reload"
|
||||||
|
[~ adult-gate]
|
||||||
--
|
--
|
||||||
:: adult ames, after metamorphosis from larva
|
:: adult ames, after metamorphosis from larva
|
||||||
::
|
::
|
||||||
|
Loading…
Reference in New Issue
Block a user