You've already forked godot
mirror of
https://github.com/godotengine/godot.git
synced 2025-11-04 12:00:25 +00:00
Modernize Thread
- Based on C++11's `thread` and `thread_local` - No more need to allocate-deallocate or check for null - No pointer anymore, just a member variable - Platform-specific implementations no longer needed (except for the few cases of non-portable functions) - Simpler for `NO_THREADS` - Thread ids are now the same across platforms (main is 1; others follow)
This commit is contained in:
@@ -87,7 +87,7 @@ JNIEXPORT void JNICALL Java_org_godotengine_godot_GodotLib_initialize(JNIEnv *en
|
||||
godot_java = new GodotJavaWrapper(env, activity, godot_instance);
|
||||
godot_io_java = new GodotIOJavaWrapper(env, godot_java->get_member_object("io", "Lorg/godotengine/godot/GodotIO;", env));
|
||||
|
||||
ThreadAndroid::make_default(jvm);
|
||||
init_thread_jandroid(jvm, env);
|
||||
|
||||
jobject amgr = env->NewGlobalRef(p_asset_manager);
|
||||
|
||||
@@ -119,7 +119,7 @@ JNIEXPORT void JNICALL Java_org_godotengine_godot_GodotLib_ondestroy(JNIEnv *env
|
||||
}
|
||||
|
||||
JNIEXPORT void JNICALL Java_org_godotengine_godot_GodotLib_setup(JNIEnv *env, jclass clazz, jobjectArray p_cmdline) {
|
||||
ThreadAndroid::setup_thread();
|
||||
setup_android_thread();
|
||||
|
||||
const char **cmdline = nullptr;
|
||||
jstring *j_cmdline = nullptr;
|
||||
@@ -206,7 +206,7 @@ JNIEXPORT void JNICALL Java_org_godotengine_godot_GodotLib_step(JNIEnv *env, jcl
|
||||
return;
|
||||
|
||||
if (step == 0) {
|
||||
// Since Godot is initialized on the UI thread, _main_thread_id was set to that thread's id,
|
||||
// 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());
|
||||
++step;
|
||||
@@ -382,7 +382,7 @@ JNIEXPORT void JNICALL Java_org_godotengine_godot_GodotLib_focusout(JNIEnv *env,
|
||||
}
|
||||
|
||||
JNIEXPORT void JNICALL Java_org_godotengine_godot_GodotLib_audio(JNIEnv *env, jclass clazz) {
|
||||
ThreadAndroid::setup_thread();
|
||||
setup_android_thread();
|
||||
AudioDriverAndroid::thread_func(env);
|
||||
}
|
||||
|
||||
|
||||
Reference in New Issue
Block a user