Commit ac7d0d21 authored by Pasquale Boemio's avatar Pasquale Boemio

added support to native threads

parent d5475484
...@@ -72,7 +72,15 @@ void jniShutdown() { ...@@ -72,7 +72,15 @@ void jniShutdown() {
JNIEnv * jniGetThreadEnv() { JNIEnv * jniGetThreadEnv() {
assert(g_cachedJVM); assert(g_cachedJVM);
JNIEnv * env = nullptr; JNIEnv * env = nullptr;
const jint get_res = g_cachedJVM->GetEnv(reinterpret_cast<void**>(&env), JNI_VERSION_1_6); jint get_res = g_cachedJVM->GetEnv(reinterpret_cast<void**>(&env), JNI_VERSION_1_6);
if (get_res == JNI_EDETACHED) {
get_res = g_cachedJVM->AttachCurrentThread(&env, nullptr);
thread_local struct DetachOnExit {
~DetachOnExit() {
g_cachedJVM->DetachCurrentThread();
}
} detachOnExit;
}
if (get_res != 0 || !env) { if (get_res != 0 || !env) {
// :( // :(
std::abort(); std::abort();
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment