mirror of https://github.com/kivy/pyjnius.git
add a jnius.detach() method to detach a thread that used some jni.
This cannot be automatic as jnius do not control the thread creation, so it cannot add a callabck to autocall this method. It must be added by the user before the thread leave, if it used pyjnius inside. Ref #107 Ref #97
This commit is contained in:
parent
614e43626a
commit
857e4c762a
|
@ -401,4 +401,5 @@ cdef extern from "jni.h":
|
|||
|
||||
ctypedef struct JNIInvokeInterface:
|
||||
jint (*AttachCurrentThread)(JavaVM *, JNIEnv **, void *)
|
||||
jint (*DetachCurrentThread)(JavaVM *)
|
||||
|
||||
|
|
|
@ -87,7 +87,7 @@ Python::
|
|||
|
||||
__all__ = ('JavaObject', 'JavaClass', 'JavaMethod', 'JavaField',
|
||||
'MetaJavaClass', 'JavaException', 'cast', 'find_javaclass',
|
||||
'PythonJavaClass', 'java_method')
|
||||
'PythonJavaClass', 'java_method', 'detach')
|
||||
|
||||
from libc.stdlib cimport malloc, free
|
||||
from functools import partial
|
||||
|
|
|
@ -19,3 +19,7 @@ cdef JNIEnv *get_jnienv() except NULL:
|
|||
jvm[0].AttachCurrentThread(jvm, &env, NULL)
|
||||
return env
|
||||
|
||||
|
||||
def detach():
|
||||
jvm[0].DetachCurrentThread(jvm)
|
||||
|
||||
|
|
Loading…
Reference in New Issue