/* * Callback we get when the JVM is initialized. We use this time to setup our GC thread */ static void JNICALL callbackVMInit(jvmtiEnv * jvmti, JNIEnv * env, jthread thread) { jvmtiError err; err = jvmti->RunAgentThread(alloc_thread(env), &gcWorker, NULL, JVMTI_THREAD_MAX_PRIORITY); check_jvmti_error(jvmti, err, "Unable to run agent cleanup thread"); }
/** thread_current : void -> 'thread <doc>Returns the current thread</doc> **/ static value thread_current() { vthread *t = neko_thread_current(); // should only occur for main thread ! if( t == NULL ) { neko_vm *vm = neko_vm_current(); t = alloc_thread(vm); neko_vm_set_custom(vm,k_thread,t); } return t->v; }
static void thread_init( void *_p ) { tparams *p = (tparams*)_p; neko_vm *vm; // init the VM and set current thread vm = neko_vm_alloc(NULL); p->t = alloc_thread(vm); neko_vm_jit(vm,p->jit); neko_vm_select(vm); neko_vm_set_custom(vm,k_thread,p->t); }
/* Callback for JVMTI_EVENT_VM_INIT */ static void JNICALL vm_init(jvmtiEnv *jvmti, JNIEnv *env, jthread thread) { jvmtiError err; stdout_message("VMInit...\n"); err = (*jvmti)->RunAgentThread(jvmti, alloc_thread(env), &worker, NULL, JVMTI_THREAD_MAX_PRIORITY); check_jvmti_error(jvmti, err, "running agent thread"); }
/* Callback for JVMTI_EVENT_VM_INIT */ static void JNICALL vm_init(jvmtiEnv *jvmti, JNIEnv *env, jthread thread) { jvmtiError err; fprintf(log, "VMInit...\n"); err = jvmti->RunAgentThread(alloc_thread(env), &worker2, NULL, JVMTI_THREAD_MAX_PRIORITY); if (err != JVMTI_ERROR_NONE) { fprintf(log, "ERROR: RunAgentProc failed (worker2), err=%d\n", err); } }
struct thread *create_thread(thread_fun function, void *data) { struct thread *thr; thr = alloc_thread(); if(thr == NULL) { return NULL; } thr->function = function; thr->data = data; return thr; }