Logo AND Algorithmique Numérique Distribuée

Public GIT Repository
New function Process.getCount()
authorMartin Quinson <martin.quinson@loria.fr>
Thu, 8 Nov 2012 22:53:48 +0000 (23:53 +0100)
committerMartin Quinson <martin.quinson@loria.fr>
Thu, 8 Nov 2012 22:53:48 +0000 (23:53 +0100)
ChangeLog
org/simgrid/msg/Process.java
src/jmsg_process.c
src/jmsg_process.h

index 7562757..9dccfa1 100644 (file)
--- a/ChangeLog
+++ b/ChangeLog
@@ -13,6 +13,8 @@ SimGrid-java (3.8) unstable; urgency=low
  * Add Process.getProperty, Host.getProperty, Host.getProperty: allows
    you to retrieve the properties of the processes/hosts
  * Deprecate Msg.clean(): you can just forget about it now.
+ * New function Process.getCount(), that only works when compiling
+   with the not yet released version 3.9 of the C library.
  
  * New context factory based on Coroutines. It mandates a modified JVM
    but then, the simulations run about five times faster, and there is
index e8ed072..9d9065a 100644 (file)
@@ -406,4 +406,11 @@ public abstract class Process implements Runnable {
        static {
                nativeInit();
        }
+       /**
+        * This static method returns the current amount of processes running
+        *
+        * @return                      The count of the running processes
+        */ 
+       public native static int getCount();
+
 }
index 7773eeb..aaa73e7 100644 (file)
@@ -266,7 +266,8 @@ 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
+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;
@@ -285,7 +286,8 @@ JNIEXPORT void JNICALL Java_org_simgrid_msg_Process_setAutoRestart
     xbt_ex_free(e);
   }
 }
-JNIEXPORT void JNICALL Java_org_simgrid_msg_Process_restart
+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;
@@ -318,7 +320,8 @@ Java_org_simgrid_msg_Process_isSuspended(JNIEnv * env,
   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;
@@ -398,3 +401,15 @@ Java_org_simgrid_msg_Process_setKillTime (JNIEnv *env , jobject jprocess, jdoubl
        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
+}
index cfc7051..566a877 100644 (file)
@@ -261,4 +261,8 @@ JNIEXPORT void JNICALL Java_org_simgrid_msg_Process_migrate
 JNIEXPORT void JNICALL Java_org_simgrid_msg_Process_setKillTime
     (JNIEnv *, jobject, jdouble);
 
+JNIEXPORT jint JNICALL
+Java_org_simgrid_msg_Process_getCount(JNIEnv * env, jclass cls);
+
+
 #endif                          /* !MSG_JPROCESS_H */