mirror of
https://github.com/dolphin-emu/dolphin.git
synced 2025-05-14 07:02:41 +00:00
android: thread local env
This commit is contained in:
parent
3132839113
commit
0dec8feadb
6 changed files with 33 additions and 70 deletions
Source/Android/jni/AndroidCommon
|
@ -29,9 +29,27 @@ static jmethodID s_do_rumble;
|
|||
|
||||
namespace IDCache
|
||||
{
|
||||
JavaVM* GetJavaVM()
|
||||
JNIEnv* GetEnvForThread()
|
||||
{
|
||||
return s_java_vm;
|
||||
thread_local static struct OwnedEnv
|
||||
{
|
||||
OwnedEnv()
|
||||
{
|
||||
status = s_java_vm->GetEnv(reinterpret_cast<void**>(&env), JNI_VERSION_1_6);
|
||||
if (status == JNI_EDETACHED)
|
||||
s_java_vm->AttachCurrentThread(&env, nullptr);
|
||||
}
|
||||
|
||||
~OwnedEnv()
|
||||
{
|
||||
if (status == JNI_EDETACHED)
|
||||
s_java_vm->DetachCurrentThread();
|
||||
}
|
||||
|
||||
int status;
|
||||
JNIEnv* env = nullptr;
|
||||
} owned;
|
||||
return owned.env;
|
||||
}
|
||||
|
||||
jclass GetNativeLibraryClass()
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue