Are there any plans on thread-safety on function level for GDScript? #4981
just-like-that
started this conversation in
Scripting
Replies: 2 comments 2 replies
-
How are you using threads? By default you aren't, so instances calling each other is not a threading concern. If you are using threads, know that you can use call_deferred and set_deferred if you need to call from a secondary thread to the main one. |
Beta Was this translation helpful? Give feedback.
2 replies
-
I've found an interesting demo regarding our discussion: |
Beta Was this translation helpful? Give feedback.
0 replies
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
-
As multi-threading is getting more and more a topic with the launch of Godot 4.0 are there any plans on incorporating thread-safety on function level of class instances?
What I mean by that is something similar to the keyword "synchronized" of Java class methods.
How would I do it in GDScript?
By annotating a method with
@synchronized
the method would be run only once per instance at the same time.It acts as some kind of watch-dog that is taking care that certain code is only run by one thread at the same time.
It would be neat to have this support on language level without the need to use mutexes etc. ...
Is this idea good enough to make a proposal out of it?
In my use case I have a global counter which is accessed by other instances.
Beta Was this translation helpful? Give feedback.
All reactions