aboutsummaryrefslogtreecommitdiffstats
path: root/sample-java/src/main/cpp/ComputeInNativeProxy.cpp
diff options
context:
space:
mode:
authorLandrelYoung <landerlyoung@gmail.com>2019-10-09 15:10:14 +0800
committerLandrelYoung <landerlyoung@gmail.com>2019-10-09 15:10:14 +0800
commit41ff638de71bb5db27b6898f93fd62d94101bccd (patch)
tree9298c5dfd470f14b69ec0462a4bbb30de809a535 /sample-java/src/main/cpp/ComputeInNativeProxy.cpp
parent62f09fa64e7caaf2af16bdabeea3413d521782ca (diff)
rename samples
Diffstat (limited to 'sample-java/src/main/cpp/ComputeInNativeProxy.cpp')
-rw-r--r--sample-java/src/main/cpp/ComputeInNativeProxy.cpp62
1 files changed, 62 insertions, 0 deletions
diff --git a/sample-java/src/main/cpp/ComputeInNativeProxy.cpp b/sample-java/src/main/cpp/ComputeInNativeProxy.cpp
new file mode 100644
index 0000000..9f71224
--- /dev/null
+++ b/sample-java/src/main/cpp/ComputeInNativeProxy.cpp
@@ -0,0 +1,62 @@
+/**
+ * File generated by Jenny -- https://github.com/LanderlYoung/Jenny
+ *
+ * DO NOT EDIT THIS FILE.
+ *
+ * For bug report, please refer to github issue tracker https://github.com/LanderlYoung/Jenny/issues,
+ * or contact author landerlyoung@gmail.com.
+ */
+#include "ComputeInNativeProxy.h"
+
+
+jclass ComputeInNativeProxy::sClazz = nullptr;
+
+// thread safe init
+std::mutex ComputeInNativeProxy::sInitLock;
+std::atomic_bool ComputeInNativeProxy::sInited;
+
+/*static*/ bool ComputeInNativeProxy::initClazz(JNIEnv *env) {
+#define JENNY_CHECK_NULL(val) \
+ do { \
+ if ((val) == nullptr) { \
+ return false; \
+ } \
+ } while(false)
+
+ if (!sInited) {
+ std::lock_guard<std::mutex> lg(sInitLock);
+ if (!sInited) {
+ auto clazz = env->FindClass(FULL_CLASS_NAME);
+ JENNY_CHECK_NULL(clazz);
+ sClazz = reinterpret_cast<jclass>(env->NewGlobalRef(clazz));
+ env->DeleteLocalRef(clazz);
+ JENNY_CHECK_NULL(sClazz);
+
+
+
+ sField_nativeContext_0 = env->GetFieldID(sClazz, "nativeContext", "J");
+ JENNY_CHECK_NULL(sField_nativeContext_0);
+
+
+ sInited = true;
+ }
+ }
+#undef JENNY_CHECK_NULL
+ return true;
+}
+
+/*static*/ void ComputeInNativeProxy::releaseClazz(JNIEnv *env) {
+ if (sInited) {
+ std::lock_guard<std::mutex> lg(sInitLock);
+ if (sInited) {
+ env->DeleteLocalRef(sClazz);
+ sInited = false;
+ }
+ }
+}
+
+
+
+jfieldID ComputeInNativeProxy::sField_nativeContext_0;
+
+