1
0
mirror of https://github.com/godotengine/godot.git synced 2025-11-04 12:00:25 +00:00

Fix thread IDs.

On Linux, thread IDs were not properly assigned with the current approach.
The line:
`std::thread new_thread(&Thread::callback, _thread_id_hash(thread.get_id()), p_settings, p_callback, p_user);`
does not work because the thread ID is not assigned until the thread starts.

This PR changes the behavior to use manually generated thread IDs. Additionally, if a thread is (or may have been created) outside Godot, the method `Thread::attach_external_thread` was added.
This commit is contained in:
Juan Linietsky
2023-04-22 15:34:16 +02:00
parent 24cb43a874
commit a37c30dfc9
7 changed files with 47 additions and 42 deletions

View File

@@ -244,7 +244,7 @@ JNIEXPORT jboolean JNICALL Java_org_godotengine_godot_GodotLib_step(JNIEnv *env,
if (step.get() == 0) {
// Since Godot is initialized on the UI thread, main_thread_id was set to that thread's id,
// but for Godot purposes, the main thread is the one running the game loop
Main::setup2(Thread::get_caller_id());
Main::setup2();
input_handler = new AndroidInputHandler();
step.increment();
return true;