X-Git-Url: http://info.iut-bm.univ-fcomte.fr/pub/gitweb/simgrid.git/blobdiff_plain/138e6f86566611611b1115c957cae0a1c6a85a4b..70d44043847d29a634b9315100557a8e9698714d:/src/bindings/java/jmsg_process.cpp diff --git a/src/bindings/java/jmsg_process.cpp b/src/bindings/java/jmsg_process.cpp index e9a59f6451..7ddb3b6c20 100644 --- a/src/bindings/java/jmsg_process.cpp +++ b/src/bindings/java/jmsg_process.cpp @@ -6,6 +6,8 @@ /* This program is free software; you can redistribute it and/or modify it * under the terms of the license (GNU LGPL) which comes with this package. */ +#include + #include "jmsg_process.h" #include "jmsg.h" @@ -25,14 +27,9 @@ jfieldID jprocess_field_Process_name; jfieldID jprocess_field_Process_pid; jfieldID jprocess_field_Process_ppid; -JNIEXPORT void JNICALL -Java_org_simgrid_msg_Process_exit(JNIEnv *env, jobject jprocess) { - -} - jobject native_to_java_process(msg_process_t process) { - simgrid::java::JavaContext* context = (simgrid::java::JavaContext*) MSG_process_get_smx_ctx(process); + simgrid::kernel::context::JavaContext* context = (simgrid::kernel::context::JavaContext*) MSG_process_get_smx_ctx(process); return context->jprocess; } @@ -49,7 +46,7 @@ void jprocess_delete_global_ref(jobject jprocess, JNIEnv * env) void jprocess_join(jobject jprocess, JNIEnv * env) { msg_process_t process = jprocess_to_native_process(jprocess,env); - simgrid::java::JavaContext* context = (simgrid::java::JavaContext*) MSG_process_get_smx_ctx(process); + simgrid::kernel::context::JavaContext* context = (simgrid::kernel::context::JavaContext*) MSG_process_get_smx_ctx(process); xbt_os_thread_join(context->thread,nullptr); } @@ -142,11 +139,11 @@ JNIEXPORT void JNICALL Java_org_simgrid_msg_Process_create(JNIEnv * env, jobject jdouble jkill = env->GetDoubleField(jprocess, jprocess_field_Process_killTime); /* Actually build the MSG process */ process = MSG_process_create_with_environment(name, [](int argc, char** argv) -> int { - smx_process_t process = SIMIX_process_self(); + smx_actor_t process = SIMIX_process_self(); // This is the jprocess passed as environment. // It would be simplet if we could use a closure. jobject jprocess = (jobject) MSG_process_get_data(process); - simgrid::java::java_main_jprocess(jprocess); + simgrid::kernel::context::java_main_jprocess(jprocess); return 0; }, jprocess, host, @@ -352,7 +349,11 @@ JNIEXPORT void JNICALL Java_org_simgrid_msg_Process_kill(JNIEnv * env, jobject j return; } - MSG_process_kill(process); + try { + MSG_process_kill(process); + } catch (xbt_ex& ex) { + XBT_VERB("This process just killed itself."); + } } JNIEXPORT void JNICALL Java_org_simgrid_msg_Process_migrate(JNIEnv * env, jobject jprocess, jobject jhost) @@ -381,6 +382,11 @@ JNIEXPORT void JNICALL Java_org_simgrid_msg_Process_migrate(JNIEnv * env, jobjec env->SetObjectField(jprocess, jprocess_field_Process_host, jhost); } +JNIEXPORT void JNICALL Java_org_simgrid_msg_Process_yield(JNIEnv* env, jclass cls) +{ + MSG_process_yield(); +} + JNIEXPORT void JNICALL Java_org_simgrid_msg_Process_setKillTime (JNIEnv *env , jobject jprocess, jdouble jkilltime) { msg_process_t process = jprocess_to_native_process(jprocess, env); MSG_process_set_kill_time(process, (double)jkilltime); @@ -390,4 +396,4 @@ JNIEXPORT jint JNICALL Java_org_simgrid_msg_Process_getCount(JNIEnv * env, jclas return (jint) MSG_process_get_number(); } -} +} // extern C