Logo AND Algorithmique Numérique Distribuée

Public GIT Repository
Add Process.setAutoRestart
[simgrid.git] / src / jmsg_process.c
index f05d8be..a071d98 100644 (file)
@@ -1,6 +1,6 @@
 /* Functions related to the java process instances.                         */
 
-/* Copyright (c) 2007, 2008, 2009, 2010. The SimGrid Team.
+/* Copyright (c) 2007-2012. The SimGrid Team.
  * All rights reserved.                                                     */
 
 /* This program is free software; you can redistribute it and/or modify it
@@ -228,6 +228,7 @@ Java_org_simgrid_msg_Process_suspend(JNIEnv * env,
                  bprintf("unexpected error , please report this bug"));
 
 }
+
 JNIEXPORT void JNICALL
 Java_org_simgrid_msg_Process_resume(JNIEnv * env,
                                      jobject jprocess)
@@ -245,6 +246,43 @@ Java_org_simgrid_msg_Process_resume(JNIEnv * env,
   jxbt_check_res("MSG_process_resume()", rv, MSG_OK,
                  bprintf("unexpected error , please report this bug"));
 }
+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;
+
+  if (!process) {
+    jxbt_throw_notbound(env, "process", jprocess);
+    return;
+  }
+
+  TRY {
+    MSG_process_restart(process);
+  }
+  CATCH (e) {
+    xbt_ex_free(e);
+  }
+
+}
 JNIEXPORT jboolean JNICALL
 Java_org_simgrid_msg_Process_isSuspended(JNIEnv * env,
                                          jobject jprocess)