Example #1
0
static jint AttachCurrentThreadAsDaemon(JavaVM* vm, void** penv, void* args) {
    char* name = NULL;
    Object* group = NULL;
    if (args) {
        name = ((JavaVMAttachArgs*) args)->name;
        group = (Object*) ((JavaVMAttachArgs*) group)->name;
    }
    return rvmAttachCurrentThreadAsDaemon((VM*) vm, (Env**) penv, name, group);
}
Example #2
0
File: bc.c Project: SinoJerk/robovm
Env* _bcAttachThreadFromCallback(void) {
    Env* env = rvmGetEnv();
    if (!env) {
        // This thread has never been attached or it has been
        // attached, then detached in the TLS destructor. In the
        // latter case, we are getting called back by native code
        // e.g. an auto-release pool, that is triggered after
        // the TLS destructor.
        if (rvmAttachCurrentThreadAsDaemon(vm, &env, NULL, NULL) != JNI_OK) {
            rvmAbort("Failed to attach thread in callback");
        }
    }
    return env;
}