-
-
Notifications
You must be signed in to change notification settings - Fork 99
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Improve Thread for better usability #3163
Comments
See potential solution godotengine/godot#34862. |
Yes, that will help a lot. Looking forward to 4.0. The other two items would still be nice to have, though. |
Discussing the point specifically about signals: PRs for emitting a signal when a thread is complete have been rejected/closed several times (here and here), and I think for good reason (godotengine/godot#34862 (comment)). Say that you spawn a worker thread that spawns additional subthreads. When those subthreads finish, you would expect the signal/callback to be deferred to the primary worker. A thread itself does not have a message queue to handle deferred calls, so
(Of course, a fair counter-argument is that people don't usually nest threads, and if they do, they likely understand the limitations/limitations can be documented.) |
Describe the project you are working on
A non-game desktop application using Control nodes.
Describe the problem or limitation you are having in your project
Sometimes it is needed to run a long task in a thread to avoid blocking the GUI, proceed to something else, and then react as soon as that task is done. I found this process to be a little convoluted is GDScript. There are two main issues:
Therefore, if you want to execute a function in a thread, you need to implement:
This results in quite a bit of code for something I feel could be much simpler. I dove into this problem, and before I realized it, I had a whole wrapper class written to handle this (see below).
Describe the feature / enhancement and how it helps to overcome the problem or limitation
Any of these three additions can drastically reduce the amount of boilerplate code required to use threads. Implementing all three of them would be ideal.
Describe how your proposal will work, with code, pseudo-code, mock-ups, and/or diagrams
I think the previous section already covers it.
If this enhancement will not be used often, can it be worked around with a few lines of script?
Yes, but it is kind of not trivial, especially for novices at programming. Here's what I came up with for a general solution:
Is there a reason why this should be core and not an add-on in the asset library?
These additions will help new users get the hang of threads, and they fit well with the way other things are done in Godot.
The text was updated successfully, but these errors were encountered: