Logo AND Algorithmique Numérique Distribuée

Public GIT Repository
Merge concerns - Adrien
[simgrid.git] / org / simgrid / msg / Comm.java
index 2865757..423371d 100644 (file)
@@ -12,6 +12,14 @@ package org.simgrid.msg;
  * between processes.
  */
 public class Comm {
+       /**
+        * Indicates if the communication is a receiving communication
+        */
+       protected boolean receiving;
+       /**
+        * Indicates if the communication is finished
+        */
+       protected boolean finished = false;
        /**
         * Represents the bind between the java comm and the
         * native C comm. You must never access it, since it is 
@@ -21,7 +29,7 @@ public class Comm {
        /**
         * Represents the bind for the task object pointer. Don't touch it.
         */
-       public long bindTask = 0;
+       public long taskBind = 0;
        /**
         * Task associated with the comm. Beware, it can be null 
         */
@@ -36,19 +44,24 @@ public class Comm {
        /**
         * Finalize the communication object, destroying it.
         */
-       protected void finalize() {
-               unbind();
+       protected void finalize() throws Throwable {
+               destroy();
        }
        /**
         * Unbind the communication object
         */
-       public native void unbind();
+       protected native void destroy() throws NativeException;
        /**
         * Returns if the communication is finished or not.
         * If the communication has finished and there was an error,
         * raise an exception.
         */
        public native boolean test() throws TransferFailureException, HostFailureException, TimeoutException ;
+       /**
+        * Wait for the completion of the communication.
+        * Throws an exception if there were an error in the communication.
+        */
+       public native void waitCompletion(double timeout) throws TransferFailureException, HostFailureException, TimeoutException;
        /**
         * Returns the task associated with the communication.
         * if the communication isn't finished yet, will return null.
@@ -56,5 +69,12 @@ public class Comm {
        public Task getTask() {
                return task;
        }
-       
+
+       /**
+        * Class initializer, to initialize various JNI stuff
+        */
+       public static native void nativeInit();
+       static {
+               nativeInit();
+       }       
 }