diff options
author | Sven Gothel <[email protected]> | 2013-04-08 02:48:57 +0200 |
---|---|---|
committer | Sven Gothel <[email protected]> | 2013-04-08 02:48:57 +0200 |
commit | 64fd6eef879f7453b491a9df421faf2d47da9d7f (patch) | |
tree | c05eff27240695ea5e14c5a384cdbce5dbaf6732 /src/newt/native/NewtCommon.c | |
parent | ed596d9a329f1788979e148a4d09df7815ada527 (diff) |
NEWT/Native: NewtCommon_GetJNIEnv(..) adding 'asDaemon' flag, used by all OSX JNI attachments to save time since detachment is skipped.
Diffstat (limited to 'src/newt/native/NewtCommon.c')
-rw-r--r-- | src/newt/native/NewtCommon.c | 9 |
1 files changed, 7 insertions, 2 deletions
diff --git a/src/newt/native/NewtCommon.c b/src/newt/native/NewtCommon.c index 7f070e7d3..c294b6e0b 100644 --- a/src/newt/native/NewtCommon.c +++ b/src/newt/native/NewtCommon.c @@ -72,7 +72,7 @@ jchar* NewtCommon_GetNullTerminatedStringChars(JNIEnv* env, jstring str) return strChars; } -JNIEnv* NewtCommon_GetJNIEnv(JavaVM * jvmHandle, int jvmVersion, int * shallBeDetached) { +JNIEnv* NewtCommon_GetJNIEnv(JavaVM * jvmHandle, int jvmVersion, int asDaemon, int * shallBeDetached) { JNIEnv* curEnv = NULL; JNIEnv* newEnv = NULL; int envRes; @@ -81,7 +81,12 @@ JNIEnv* NewtCommon_GetJNIEnv(JavaVM * jvmHandle, int jvmVersion, int * shallBeDe envRes = (*jvmHandle)->GetEnv(jvmHandle, (void **) &curEnv, jvmVersion) ; if( JNI_EDETACHED == envRes ) { // detached thread - attach to JVM - if( JNI_OK != ( envRes = (*jvmHandle)->AttachCurrentThread(jvmHandle, (void**) &newEnv, NULL) ) ) { + if( asDaemon ) { + envRes = (*jvmHandle)->AttachCurrentThreadAsDaemon(jvmHandle, (void**) &newEnv, NULL); + } else { + envRes = (*jvmHandle)->AttachCurrentThread(jvmHandle, (void**) &newEnv, NULL); + } + if( JNI_OK != envRes ) { fprintf(stderr, "JNIEnv: can't attach thread: %d\n", envRes); return NULL; } |