Routing 101 Part 1
Rudiments
Imagine that a Container contains 2 children, A and B.
The Container, P, inhales a single message from its input queue and begins to process it, by punting the work to its children.
The Container, P, sends the message down to its child A.
A does something with the message. We don’t know - nor care - whether A is a piece of code or whether A is yet another Container with its own children.
While A is processing the message, P is “busy” and cannot consume another message.
P is “busy” while, either A or B is “busy”. In this early case, only A is busy, and, B is idle.
During processing, A, generates an output message and leaves the message on its output queue.
When A is finished, P, routes A’s messages to their final destinations. In this case, A’s output queue contains only a single output message. That message is removed from A’s output queue and put - routed across - into B’s input queue. This routing is done by P.
Now, A is idle and B is “busy” (“ready” to do some work). P checks its children and discovers that not all children are finished yet. In this case, A is idle, but, B is raring to go. Because of this situation, P is still “busy” and does not pull any more messages from its own input queue.
P fires B. B produces a single message on its output queue.
When B finishes, P cleans up and routes it’s children's messages. In this case, a message is removed from B’s output queue and routed up to P’s output queue.
Now, A and B are idle, hence, P is idle or ready and can consume another input message. The process repeats until there are no more messages left on P’s input queue, in which case P becomes idle.
Basic Routings
down input of Container to input(s) of child(ren)
across output of child to input of child
up output of child to output of Container
...
To be considered...
What if A and/or B produce multiple output messages?
What if A and/or B have multiple outputs and multiple inputs?
What if the circuit diagram contains more children, say C?
What if C’s input comes from A and B?
What if A’s message is destined for B’s input, and, C’s input?
We’ve discussed 3 common kinds of routing - down, across, up. Are there any others? (Hint: through).
See Also
References: https://guitarvydas.github.io/2024/01/06/References.html
Blog: https://guitarvydas.github.io/
Videos: https://www.youtube.com/@programmingsimplicity2980
Discord: https://discord.gg/Jjx62ypR
Leanpub: https://leanpub.com/u/paul-tarvydas
Gumroad: https://tarvydas.gumroad.com
Twitter: @paul_tarvydas