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

Let platforms set their own Thread implementation again (support was removed in 3.3) #3277

Closed
lucypero opened this issue Sep 11, 2021 · 5 comments
Milestone

Comments

@lucypero
Copy link

Describe the project you are working on

We need to ship a game on >=3.3 and be able to set the stack size at thread creation. We need to use the native platform API for creating threads instead of std::thread

Describe the problem or limitation you are having in your project

Since 3.3, Godot doesn't let each platform set their own Thread implementation. We need to do this, as std::thread doesn't let you set a stack size for the thread. We need to increase the stack size on threads and thus we want to use the native API for creating threads.

Describe the feature / enhancement and how it helps to overcome the problem or limitation

Let each platform easily set their own Thread implementation, without using std::thread

Describe how your proposal will work, with code, pseudo-code, mock-ups, and/or diagrams

Make thread.h more extensible like it was before 3.3

If this enhancement will not be used often, can it be worked around with a few lines of script?

No. The only solution right now is to compile a different thread.cpp instead of the core one, and add #ifdef every time thread.h is included in the engine.

Is there a reason why this should be core and not an add-on in the asset library?

This is about making Godot extensible and easily workable on any platform.

@punto-
Copy link

punto- commented Sep 15, 2021

To add more detail, this is for a console, where the thread stack size can be configured, and the std implementation is crashing with insufficient stack size (this could be a more general godot issue, maybe some code could be optimized to use less stack?). We used to be able to re-implement the thread for the platform, but since the new version of the Thread class that uses the std implementation, we can't. This was fine as first, since the platform has std::thread and friends (in fact we're using the std::mutex and the others), but now we run into this issue. I think it's crucial to allow a platform specific implementation for all the threading classes, even if we think it won't be necessary, this kind of thing still happens, it just makes the engine portable.

@Calinou
Copy link
Member

Calinou commented Sep 15, 2021

cc @RandomShaper

@Calinou Calinou changed the title Let platforms set their own Thread implementation Let platforms set their own Thread implementation again (support was removed in 3.3) Sep 15, 2021
@lucypero
Copy link
Author

Possible solution:

godotengine/godot#52734

@RandomShaper
Copy link
Member

Makes sense to me.

@akien-mga
Copy link
Member

Fixed by godotengine/godot#52734.

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

No branches or pull requests

5 participants