forked from ClickHouse/ClickHouse
-
Notifications
You must be signed in to change notification settings - Fork 17
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
add context clean when unload lib (#40)
* add context clean and refactor jni code * change init * add broadcast clean
- Loading branch information
1 parent
c695853
commit 7abd83d
Showing
21 changed files
with
204 additions
and
145 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,31 @@ | ||
#include "JNIUtils.h" | ||
|
||
namespace local_engine | ||
{ | ||
|
||
JavaVM * JNIUtils::vm = nullptr; | ||
|
||
JNIEnv * JNIUtils::getENV(int * attach) | ||
{ | ||
if (vm == nullptr) return nullptr; | ||
|
||
*attach = 0; | ||
JNIEnv *jni_env = nullptr; | ||
|
||
int status = vm->GetEnv(reinterpret_cast<void **>(&jni_env), JNI_VERSION_1_8); | ||
|
||
if (status == JNI_EDETACHED || jni_env == nullptr) { | ||
status = vm->AttachCurrentThread(reinterpret_cast<void **>(&jni_env), nullptr); | ||
if (status < 0) { | ||
jni_env = nullptr; | ||
} else { | ||
*attach = 1; | ||
} | ||
} | ||
return jni_env; | ||
} | ||
void JNIUtils::detachCurrentThread() | ||
{ | ||
vm->DetachCurrentThread(); | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,17 @@ | ||
#pragma once | ||
#include <jni.h> | ||
|
||
namespace local_engine | ||
{ | ||
class JNIUtils | ||
{ | ||
public: | ||
static JavaVM * vm; | ||
|
||
static JNIEnv * getENV(int *attach); | ||
|
||
static void detachCurrentThread(); | ||
}; | ||
} | ||
|
||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.