Panoyan rafi.panoyan(panoyanrafi-panoyan)

yield ready breaks the callback chain ?

The doc says that the _ready function of any parent node waits for all the _ready function of the children to be called first; In this video, we ask that a child node waits for its parent _ready function to be called first. Does this break the built-in _ready callback order ?
  • Nathan Lovato replied

    Yes and no. They all get called in the tree order, deep nodes first, then the nodes you explicitly used yield in wait for the node they depend upon to finish running the function.

    So you are still in control of the flow of the code.

  • p
    Panoyan rafi.panoyan(panoyanrafi-panoyan) replied

    Ok, so you could create a deadlock if 2 nodes are "yielding" each other ?

  • c
    Oleksandr Kryvosheiev(calm_alpaca) replied

    Just pinging Nathan to remind to answer :)

  • Nathan Lovato replied

    Sure, if you yield on a signal that never gets emitted or a function that never completes, you can... get just that, a coroutine that never ends.

    I'll answer in the general case, but note when you have a question like this one, I think it's more interesting to look at a concrete case where you might use such a configuration, so we can see what are the alternatives.

    You shouldn't have two nodes that yield one-another in a loop. That's a code smell. It means that each delegates work to the other, that there's tight two-ways coupling. In such a case, you might as well have just one class with all the functionality.

    Or you break the loop: only one class should delegate to another, consume the result, and coordinate execution.