I have two segments of code in a node's script that are executed in response to different signals. Since one of the code segments uses queue_free() to delete the node, I use a Mutex to make the two segments exclusive.

Each section of code is bracketed by: mutex.lock() ... mutex.unlock()


One of the bracketed code sections contains a yield: yield(get_tree().create_timer(0.25), "timeout")

The yield appears to "break" the mutex. The statement after the yield sometimes fails to work because the other segment of code executes, even though the locked mutex should prevent that from happening.

Is this the expected behavior?

I don't understand that issue thread.

I can avoid using yield() in this situation, but you're saying that it should not be used at all? Can you suggest an alternative?

It's nice that an alternative will be present in 4.0, but I can't stop working on projects for 6-12 months until 4.0-stable is available.

@DaveTheCoder said: I can avoid using yield() in this situation, but you're saying that it should not be used at all? Can you suggest an alternative?

I think you can generally use signals instead of yield(). It's not as convenient, but it's more reliable down the road.

a year later