So are Godot's Signals multithreaded?

:information_source: Attention Topic was automatically imported from the old Question2Answer platform.
:bust_in_silhouette: Asked By MaxwellDexter

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:
 obj.notify_of_something()

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.

Ertain | 2020-07-17 05:57

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.

njamster | 2020-07-17 15:03

:bust_in_silhouette: Reply From: klaas

Hi,
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.