Add thread safety to Object signals

* It turns out the majority of this work was done already by AThousandShips as part of #89451. This allows to do lock-less emitting of signals.
* This means, that only the signal map needs to be protected, making the task simple and without risk of deadlocks, or affecting performance.
* Objects can choose to not protect signals for performance (as example Node uses thread guards for protection, so these signals are not thread safe).
This commit is contained in:
Juan
2025-04-16 15:28:41 +02:00
parent dbddc9ef29
commit 2f39d8ebef
4 changed files with 128 additions and 60 deletions

View File

@@ -521,6 +521,7 @@
A signal can only be connected once to the same [Callable]. If the signal is already connected, this method returns [constant ERR_INVALID_PARAMETER] and generates an error, unless the signal is connected with [constant CONNECT_REFERENCE_COUNTED]. To prevent this, use [method is_connected] first to check for existing connections.
[b]Note:[/b] If the [param callable]'s object is freed, the connection will be lost.
[b]Note:[/b] In GDScript, it is generally recommended to connect signals with [method Signal.connect] instead.
[b]Note:[/b] This operation (and all other signal related operations) is thread-safe.
</description>
</method>
<method name="disconnect">