Attention | Topic was automatically imported from the old Question2Answer platform. | |
Asked By | avnih |
For example, say I have this function:
var event_x_happened = false
func proceed_only_if_event_x_already_happened()
if not event_x_happened:
print("waiting for it...")
yield(self, "event_x")
event_x_happened = true
print("now it happened for sure - continue")
do_some_logic()
Is it guaranteed that the signal event_x
will not be emitted on the line
print("waiting for it...")
and hence will get missed out by the line
yield(self, "event_x")
thus causing a deadlock?
If your code isn’t multithreaded, while the GDScript VM is processing proceed_only_if_event_x_already_happened()
it can’t emit the signal the yield is waiting for, because it will only return from the function when reaching the yield (and eventually call your emit_signal()
after that).
Hoimar | 2021-04-12 20:17
Thank you. That’s what I wanted to know - that once a func starts executing, no other code will be executed before it finishes (other than the cases of yield or multithreading)
avnih | 2021-04-13 12:46