[Doc] Clarify some details about deferred calls

(cherry picked from commit 1cc5b0aa0d)
This commit is contained in:
A Thousand Ships 2024-02-28 14:34:13 +01:00 committed by Rémi Verschelde
parent bbc06c7cc8
commit dd6eced096
No known key found for this signature in database
GPG Key ID: C3336907360768E1
2 changed files with 2 additions and 1 deletions

View File

@ -113,6 +113,7 @@
func _ready(): func _ready():
grab_focus.call_deferred() grab_focus.call_deferred()
[/codeblock] [/codeblock]
[b]Note:[/b] Deferred calls are processed at idle time. Idle time happens mainly at the end of process and physics frames. In it, deferred calls will be run until there are none left, which means you can defer calls from other deferred calls and they'll still be run in the current idle time cycle. This means you should not call a method deferred from itself (or from a method called by it), as this causes infinite recursion the same way as if you had called the method directly.
See also [method Object.call_deferred]. See also [method Object.call_deferred].
</description> </description>
</method> </method>

View File

@ -324,7 +324,7 @@
<param index="0" name="method" type="StringName" /> <param index="0" name="method" type="StringName" />
<description> <description>
Calls the [param method] on the object during idle time. Always returns null, [b]not[/b] the method's result. Calls the [param method] on the object during idle time. Always returns null, [b]not[/b] the method's result.
Idle time happens mainly at the end of process and physics frames. In it, deferred calls will be run until there are none left, which means you can defer calls from other deferred calls and they'll still be run in the current idle time cycle. If not done carefully, this can result in infinite recursion without causing a stack overflow, which will hang the game similarly to an infinite loop. Idle time happens mainly at the end of process and physics frames. In it, deferred calls will be run until there are none left, which means you can defer calls from other deferred calls and they'll still be run in the current idle time cycle. This means you should not call a method deferred from itself (or from a method called by it), as this causes infinite recursion the same way as if you had called the method directly.
This method supports a variable number of arguments, so parameters can be passed as a comma separated list. This method supports a variable number of arguments, so parameters can be passed as a comma separated list.
[codeblocks] [codeblocks]
[gdscript] [gdscript]