+3 votes

I just have a general question about signalling in Godot.
When I call emit_signal() does it run an emission in a for loop and then return? Or does it do this on a separate thread? Or perhaps a neat coroutine that notifies everything in a timely manner?
I'm just wondering because I want to optimise my game a bit, and if I have hundreds of objects that I need to notify of something, is it more efficient to use a signal or is it doing the same thing as:

for obj in object_list:
in Engine by (21 points)

I don't know whether Signals use threads (they sound more like coroutines, TBH). If you have several objects that need to be notified of something, a signal would work best because they're not waiting endlessly for something to call them. The objects can perform other tasks, and react to the signal when the time comes.

Well, it's open source, so you can simply take a look at what it does under the hood! From quickly skimming over it, it doesn't seem to be multithreaded and indeed just runs over a list of connections (called slot_data). I might have missed something though, so take my words with a grain of salt and check for yourself.

1 Answer

+1 vote

im pretty sure signals are not threaded. The code emits the signal and jumps right into any connected functions and after executing these it jumps right back to the next line after the emit.

by (2,940 points)
Welcome to Godot Engine Q&A, where you can ask questions and receive answers from other members of the community.

Please make sure to read How to use this Q&A? before posting your first questions.
Social login is currently unavailable. If you've previously logged in with a Facebook or GitHub account, use the I forgot my password link in the login box to set a password for your account. If you still can't access your account, send an email to webmaster@godotengine.org with your username.