mirror of
https://github.com/ilyakooo0/urbit.git
synced 2024-11-10 10:05:09 +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
|
||||
oid sha256:655bac06453b7d26ed0549576577dae1adc0fff3fefe202065cca752ff74e4e2
|
||||
size 9640752
|
||||
oid sha256:afe650a1583104e57bc83d7a0804405661b2e7a53e0673694ad53522b8894d79
|
||||
size 9526886
|
||||
|
@ -784,6 +784,13 @@
|
||||
|= [now=@da eny=@ rof=roof]
|
||||
=* larval-gate .
|
||||
=* adult-core (adult-gate +<)
|
||||
=< |%
|
||||
++ call ^call
|
||||
++ load ^load
|
||||
++ scry ^scry
|
||||
++ stay ^stay
|
||||
++ take ^take
|
||||
--
|
||||
|%
|
||||
:: +call: handle request $task
|
||||
::
|
||||
@ -796,17 +803,8 @@
|
||||
?^ dud
|
||||
~|(%ames-larval-call-dud (mean tang.u.dud))
|
||||
::
|
||||
=/ 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"
|
||||
[~ adult-gate]
|
||||
?: &(?=(^ cached-state) ?=(~ queued-events))
|
||||
(molt ~)
|
||||
:: %born: set .unix-duct and start draining .queued-events
|
||||
::
|
||||
?: ?=(%born -.task)
|
||||
@ -836,11 +834,17 @@
|
||||
~|(%ames-larval-take-dud (mean tang.u.dud))
|
||||
:: 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?
|
||||
::
|
||||
?. =(/larva wire)
|
||||
=. queued-events (~(put to queued-events) %take wire duct sign)
|
||||
[~ larval-gate]
|
||||
?. =(/larva wire) [~ larval-gate]
|
||||
:: larval event drainage timer; pop and process a queued event
|
||||
::
|
||||
?. ?=([%behn %wake *] sign)
|
||||
@ -879,20 +883,10 @@
|
||||
%call (call:adult-core [duct ~ wrapped-task]:+.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
|
||||
?: ?=(^ cached-state) (molt moves)
|
||||
~> %slog.0^leaf/"ames: metamorphosis"
|
||||
[moves adult-gate]
|
||||
:: set timer to drain next event
|
||||
@ -952,6 +946,17 @@
|
||||
=. adult-gate (load:adult-core %6 state.old)
|
||||
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
|
||||
::
|
||||
|
Loading…
Reference in New Issue
Block a user