jobject jprocess = native_to_java_process(process);
if (!jprocess) {
- jxbt_throw_jni(env, "SIMIX_process_get_jprocess() failed");
+ jxbt_throw_jni(env, "get process failed");
return NULL;
}
return jprocess;
}
+JNIEXPORT jobject JNICALL
+Java_org_simgrid_msg_Process_getProperty(JNIEnv *env, jobject jprocess, jobject jname) {
+ msg_process_t process = jprocess_to_native_process(jprocess, env);
+
+ if (!process) {
+ jxbt_throw_notbound(env, "process", jprocess);
+ return NULL;
+ }
+ const char *name = (*env)->GetStringUTFChars(env, jname, 0);
+
+ const char *property = MSG_process_get_property_value(process, name);
+ if (!property) {
+ return NULL;
+ }
+
+ jobject jproperty = (*env)->NewStringUTF(env, property);
+
+ (*env)->ReleaseStringUTFChars(env, jname, name);
+ return jproperty;
+}
JNIEXPORT jobject JNICALL
Java_org_simgrid_msg_Process_currentProcess(JNIEnv * env, jclass cls)
{
bprintf("unexpected error , please report this bug"));
}
+
JNIEXPORT void JNICALL
Java_org_simgrid_msg_Process_resume(JNIEnv * env,
jobject jprocess)
jxbt_check_res("MSG_process_resume()", rv, MSG_OK,
bprintf("unexpected error , please report this bug"));
}
-JNIEXPORT void JNICALL Java_org_simgrid_msg_Process_restart
+JNIEXPORT void JNICALL
+Java_org_simgrid_msg_Process_setAutoRestart
+ (JNIEnv *env, jobject jprocess, jboolean jauto_restart) {
+ msg_process_t process = jprocess_to_native_process(jprocess, env);
+ xbt_ex_t e;
+
+ int auto_restart = jauto_restart == JNI_TRUE ? 1 : 0;
+
+ if (!process) {
+ jxbt_throw_notbound(env, "process", jprocess);
+ return;
+ }
+
+ TRY {
+ MSG_process_auto_restart_set(process,auto_restart);
+ }
+ CATCH (e) {
+ xbt_ex_free(e);
+ }
+}
+JNIEXPORT void JNICALL
+Java_org_simgrid_msg_Process_restart
(JNIEnv *env, jobject jprocess) {
msg_process_t process = jprocess_to_native_process(jprocess, env);
xbt_ex_t e;
return (jboolean) MSG_process_is_suspended(process);
}
-JNIEXPORT void JNICALL Java_org_simgrid_msg_Process_sleep
+JNIEXPORT void JNICALL
+Java_org_simgrid_msg_Process_sleep
(JNIEnv *env, jclass cls, jlong jmillis, jint jnanos) {
double time = jmillis / 1000 + jnanos / 1000;
msg_process_t process = jprocess_to_native_process(jprocess, env);
MSG_process_set_kill_time(process, (double)jkilltime);
}
+
+JNIEXPORT jint JNICALL
+Java_org_simgrid_msg_Process_getCount(JNIEnv * env, jclass cls) {
+ /* FIXME: the next test on SimGrid version is to ensure that this still compiles with SG 3.8 while the C function were added in SG 3.9 only.
+ * This kind of pimple becomes mandatory when you get so slow to release the java version that it begins evolving further after the C release date.
+ */
+#if SIMGRID_VERSION >= 30900
+ return (jint) MSG_process_get_number();
+#else
+ return (jint) -1;
+#endif
+}