15/27
Part 4 of 7 · Lost and repeated messagesLearn and do
A finished machine answers again from memory
Now the other side. Machine 1 answered its parent, and the answer was lost. The parent's tick asks 1 again. What should 1 do?
It shouldn't ask its children again. They answered already, and asking them starts a second wave down the whole subtree. It already knows the answer, so it sends self.answer again. That's the cached answer from the write-up.
So an ask arriving at a machine has three cases:
| The machine | On an ask |
|---|---|
| has answered | send self.answer to the asker again |
| is still waiting | ignore it. Its own tick asks its children again |
| was never asked | store the parent and ask its children |
Machine 1 is still waiting for 3 when its parent asks it a second time. What should it send?
Pick an answer above to see the rest