Skip to content
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

Threading hooks are not exposed #964

Open
Zylann opened this issue Dec 15, 2022 · 0 comments
Open

Threading hooks are not exposed #964

Zylann opened this issue Dec 15, 2022 · 0 comments

Comments

@Zylann
Copy link
Collaborator

Zylann commented Dec 15, 2022

In the Thread class, Godot sets up more things than just running the work function:
https://github.com/godotengine/godot/blob/47ef0549ee490bca066ac00587076f123d973a55/core/os/thread.cpp#L53
Notably, it setups script debugging.

This isn't a problem if an extension uses the Thread class, or if you dont plan to run anything Godot-related in that thread.
However it becomes a problem if anything else needs to be used. WorkedThreadPool for example is pure C++ and does not use Godot objects, therefore it uses std::thread, but lacks the hooks Godot is setting up (while the core implementation uses Thread). This could lead to unforeseen issues related to the absence of this setup.
If threads come from a third party library, there is also no way to set this up, unless said library allows to re-implement its threads using the Thread class. The latter is also a bit inconvenient as it requires the function to run to be a method from a registered Godot object.

Perhaps GDExtension could expose two functions in order to tell Godot when a custom thread starts and ends, so that it can be made aware of them if needed?

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant