Logo AND Algorithmique Numérique Distribuée

Public GIT Repository
Merge branch 'master' of https://github.com/mpoquet/simgrid
[simgrid.git] / src / bindings / java / org / simgrid / msg / Task.java
index 615630f..26dc2b0 100644 (file)
@@ -58,8 +58,13 @@ public class Task {
         *
         * @param name          The name of the parallel task.
         * @param hosts         The list of hosts implied by the parallel task.
-        * @param flopsAmount   The amount of operations to be performed by each host of \a hosts.
-        * @param bytesAmount   A matrix describing the amount of data to exchange between hosts.
+        * @param flopsAmount   The amount of operations to be performed by each host of hosts. 
+        *                      flopsAmount[i] is the total number of operations that have to be 
+        *                      performed on hosts[i].
+        * @param bytesAmount   A matrix describing the amount of data to exchange between hosts. The 
+        *                      length of this array must be hosts.length * hosts.length. It is actually 
+        *                      used as a matrix with the lines being the source and the columns being 
+        *                      the destination of the communications.
         */ 
        public Task(String name, Host[]hosts, double[]flopsAmount, double[]bytesAmount) {
                parallelCreate(name, hosts, flopsAmount, bytesAmount);
@@ -86,7 +91,7 @@ public class Task {
         * The natively implemented method to create a MSG parallel task.
         *
         * @param name                The name of the parallel task.
-        * @param hosts                The list of hosts implied by the parallel task.
+        * @param hosts               The list of hosts implied by the parallel task.
         * @param flopsAmount         The total number of operations that have to be performed
         *                            on the hosts.
         * @param bytesAmount        An array of doubles
@@ -155,23 +160,16 @@ public class Task {
         */
        public native void execute() throws HostFailureException,TaskCancelledException;
 
-       /** Bound a computation to a certain load */
-       public native void setBound(double load); 
+       /** Changes the maximum CPU utilization of a computation task. Unit is flops/s. */
+       public native void setBound(double bound); 
 
        /** Cancels a task. */ 
        public native void cancel();
 
        /** Deletes a task once the garbage collector reclaims it */
-       @Override
-       protected void finalize() {
-               try {
-                       // Exceptions in finalizers lead to bad situations:
-                       // http://stackoverflow.com/questions/7644556/troubleshooting-a-java-memory-leak-finalization
-                       nativeFinalize();
-                       bind=0; // to avoid segfaults if the impossible happens yet again making this task surviving its finalize()
-               } catch (Throwable e) {
-                       e.printStackTrace();
-               }
+       protected void finalize() throws Throwable{
+               nativeFinalize();
+               bind=0; // to avoid segfaults if the impossible happens yet again making this task surviving its finalize()
        }
        protected native void nativeFinalize();
        /* *                       * *
@@ -254,12 +252,14 @@ public class Task {
        /**
         * Starts listening for receiving a task from an asynchronous communication
         * @param mailbox
+        * @return a Comm handler
         */
        public static native Comm irecv(String mailbox);
        /**
         * Retrieves next task from the mailbox identified by the specified name
         *
         * @param mailbox
+        * @return a Task
         */
 
        public static Task receive(String mailbox) throws TransferFailureException, HostFailureException, TimeoutException {
@@ -271,6 +271,7 @@ public class Task {
         *
         * @param mailbox
         * @param timeout
+        * @return a Task
         */
        public static Task receive(String mailbox, double timeout) throws  TransferFailureException, HostFailureException, TimeoutException {
                return receive(mailbox, timeout, null);
@@ -281,6 +282,7 @@ public class Task {
         *
         * @param mailbox
         * @param host
+        * @return a Task
         */
 
        public static Task receive(String mailbox, Host host) throws TransferFailureException, HostFailureException, TimeoutException {
@@ -293,18 +295,21 @@ public class Task {
         * @param mailbox
         * @param timeout 
         * @param host
+        * @return a Task
         */
-       public native static Task receive(String mailbox, double timeout, Host host) throws TransferFailureException, HostFailureException, TimeoutException;
+       public static native Task receive(String mailbox, double timeout, Host host) throws TransferFailureException, HostFailureException, TimeoutException;
 
        /**
         * Starts listening for receiving a task from an asynchronous communication with a capped rate
         * @param mailbox
+        * @return a Comm handler
         */
        public static native Comm irecvBounded(String mailbox, double rate);
        /**
         * Retrieves next task from the mailbox identified by the specified name with a capped rate
         *
         * @param mailbox
+        * @return a Task
         */
 
        public static Task receiveBounded(String mailbox, double rate) throws TransferFailureException, HostFailureException, TimeoutException {
@@ -316,6 +321,7 @@ public class Task {
         *
         * @param mailbox
         * @param timeout
+        * @return a Task
         */
        public static Task receiveBounded(String mailbox, double timeout, double rate) throws  TransferFailureException, HostFailureException, TimeoutException {
                return receiveBounded(mailbox, timeout, null, rate);
@@ -326,6 +332,7 @@ public class Task {
         *
         * @param mailbox
         * @param host
+        * @return a Task
         */
 
        public static Task receiveBounded(String mailbox, Host host, double rate) throws TransferFailureException, HostFailureException, TimeoutException {
@@ -339,24 +346,20 @@ public class Task {
         * @param mailbox
         * @param timeout 
         * @param host
+        * @return a Task
         */
-       public native static Task receiveBounded(String mailbox, double timeout, Host host, double rate) throws TransferFailureException, HostFailureException, TimeoutException;
+       public static native Task receiveBounded(String mailbox, double timeout, Host host, double rate) throws TransferFailureException, HostFailureException, TimeoutException;
 
 
 
        /**
         * Tests whether there is a pending communication on the mailbox identified by the specified alias, and who sent it
         */
-       public native static int listenFrom(String mailbox);
+       public static native int listenFrom(String mailbox);
        /**
         * Listen whether there is a task waiting (either for a send or a recv) on the mailbox identified by the specified alias
         */
-       public native static boolean listen(String mailbox);
-
-       /**
-        * Counts the number of tasks waiting to be received on the \a mailbox identified by the specified alia and sended by the specified \a host.
-        */
-       public native static int listenFromHost(String alias, Host host);
+       public static native boolean listen(String mailbox);
 
        /**
         * Class initializer, to initialize various JNI stuff