Logo AND Algorithmique Numérique Distribuée

Public GIT Repository
Add isend in Task
[simgrid.git] / org / simgrid / msg / Task.java
index bc2cdaa..a680e64 100644 (file)
@@ -9,7 +9,7 @@
  *(GNU LGPL) which comes with this package. 
  */
 
-package simgrid.msg;
+package org.simgrid.msg;
 
 /**
  * A task is either something to compute somewhere, or something to exchange between two hosts (or both).
@@ -64,7 +64,9 @@ public class Task {
        /* *                   * *
         * * Getters / Setters * *
         * *                   * */
-       /** Gets the name of a task */ 
+    /** Gets the name of a task
+     * @return
+     */
        public String getName() {
                return MsgNative.taskGetName(this);
        }
@@ -72,21 +74,27 @@ public class Task {
        Process getSender() {
                return MsgNative.taskGetSender(this);
        }
-       /** Gets the source of the task */ 
+    /** Gets the source of the task
+     * @return
+     */
        public Host getSource()  {
                return MsgNative.taskGetSource(this);
        }
-       /** Gets the computing amount of the task */ 
+    /** Gets the computing amount of the task
+     * @return
+     */
        public double getComputeDuration() {
                return MsgNative.taskGetComputeDuration(this);
        }
-       /** Gets the remaining computation of the task */ 
+    /** Gets the remaining computation of the task
+     * @return
+     */
        public double getRemainingDuration() {
                return MsgNative.taskGetRemainingDuration(this);
        }
        /**
         * This method sets the priority of the computation of the task.
-        * The priority doesn't affect the transfert rate. For example a
+        * The priority doesn't affect the transfer rate. For example a
         * priority of 2 will make the task receive two times more cpu than
         * the other ones.
         *
@@ -106,15 +114,16 @@ public class Task {
        /**
         * Executes a task on the location on which the process is running.
         *
-        * @exception HostFailureException,TaskCancelledException 
-        */ 
+     *
+     * @throws HostFailureException
+     * @throws TaskCancelledException
+     */
        public void execute() throws HostFailureException,TaskCancelledException {
                MsgNative.taskExecute(this);
        }
        /**
         * Cancels a task.
         *
-        * @exception NativeException if the cancellation failed.
         */ 
        public void cancel()  {
                MsgNative.taskCancel(this);
@@ -128,10 +137,20 @@ public class Task {
                        MsgNative.taskDestroy(this);
        }
 
+
+       /** Send the task asynchronously on the mailbox identified by the specified name, 
+        *  with no way to retrieve whether the communication succeeded or not
+        * 
+        */
+       public void dsend(String mailbox) {
+               MsgNative.taskDSend(mailbox, this);
+       } 
+       
        /**
         * Sends the task on the mailbox identified by the specified name 
         *
-        * @throws TimeoutException 
+     * @param mailbox
+     * @throws TimeoutException
         * @throws HostFailureException 
         * @throws TransferFailureException 
         */
@@ -142,7 +161,9 @@ public class Task {
        /**
         * Sends the task on the mailbox identified by the specified name (wait at most \a timeout seconds)
         *
-        * @exception  NativeException if the retrieval fails.
+     * @param mailbox
+     * @param timeout
+     * @exception  NativeException if the retrieval fails.
         * @throws TimeoutException 
         * @throws HostFailureException 
         * @throws TransferFailureException 
@@ -154,16 +175,34 @@ public class Task {
        /**
         * Sends the task on the mailbox identified by the specified alias  (capping the sending rate to \a maxrate) 
         *
-        * @exception  TransferFailureException, HostFailureException, TimeoutException.
+     * @param alias
+     * @param maxrate 
+     * @throws TransferFailureException
+     * @throws HostFailureException
+     * @throws TimeoutException
         */
        public void sendBounded(String alias, double maxrate) throws TransferFailureException, HostFailureException, TimeoutException {
                MsgNative.taskSendBounded(alias, this, maxrate);
        } 
-
+       /**
+        * Sends the task on the mailbox asynchronously
+        */
+       public native Comm isend(String mailbox);
+       
+       /**
+        * Starts listening for receiving a task from an asynchronous communication
+        * @param mailbox
+        * @return
+        */
+       public static native Comm irecv(String mailbox);
        /**
         * Retrieves next task from the mailbox identified by the specified name
         *
-        * @exception  TransferFailureException, HostFailureException, TimeoutException if the retrieval fails.
+     * @param mailbox
+     * @return
+     * @throws TransferFailureException
+     * @throws HostFailureException
+     * @throws TimeoutException
         */
 
        public static Task receive(String mailbox) throws TransferFailureException, HostFailureException, TimeoutException {
@@ -173,7 +212,12 @@ public class Task {
        /**
         * Retrieves next task on the mailbox identified by the specified name (wait at most \a timeout seconds)
         *
-        * @exception  TransferFailureException, HostFailureException, TimeoutException if the retrieval fails.
+     * @param mailbox
+     * @param timeout
+     * @return 
+     * @throws TransferFailureException
+     * @throws HostFailureException
+     * @throws TimeoutException
         */
        public static Task receive(String mailbox, double timeout) throws  TransferFailureException, HostFailureException, TimeoutException {
                return MsgNative.taskReceive(mailbox, timeout, null);
@@ -182,7 +226,12 @@ public class Task {
        /**
         * Retrieves next task sent by a given host on the mailbox identified by the specified alias 
         *
-        * @exception  TransferFailureException, HostFailureException, TimeoutException if the retrieval fails.
+     * @param mailbox
+     * @param host
+     * @return
+     * @throws TransferFailureException
+     * @throws TimeoutException
+     * @throws HostFailureException
         */
 
        public static Task receive(String mailbox, Host host) throws TransferFailureException, HostFailureException, TimeoutException {
@@ -192,7 +241,13 @@ public class Task {
        /**
         * Retrieves next task sent by a given host on the mailbox identified by the specified alias (wait at most \a timeout seconds)
         *
-        * @exception  TransferFailureException, HostFailureException, TimeoutException if the retrieval fails.
+     * @param mailbox
+     * @param timeout 
+     * @param host
+     * @return 
+     * @throws TransferFailureException
+     * @throws HostFailureException
+     * @throws TimeoutException
         */
        public static Task receive(String mailbox, double timeout, Host host) throws TransferFailureException, HostFailureException, TimeoutException {
                return MsgNative.taskReceive(mailbox, timeout, host);
@@ -201,14 +256,20 @@ public class Task {
        /**
         * Tests whether there is a pending communication on the mailbox identified by the specified alias, and who sent it
         *
-        */ 
+     *
+     * @param mailbox
+     * @return
+     */
        public static int listenFrom(String mailbox)  {
                return MsgNative.taskListenFrom(mailbox);
        }
        /**
         * Listen whether there is a waiting task on the mailbox identified by the specified alias
         *
-        */ 
+     *
+     * @param mailbox
+     * @return
+     */
        public static boolean listen(String mailbox)   {
                return MsgNative.taskListen(mailbox);
        }
@@ -216,7 +277,11 @@ public class Task {
        /**
         * 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.
         *
-        */ 
+     *
+     * @param alias
+     * @param host
+     * @return
+     */
        public static int listenFromHost(String alias, Host host)   {
                return MsgNative.taskListenFromHost(alias, host);
        }