Logo AND Algorithmique Numérique Distribuée

Public GIT Repository
Make bind atributes private (we don't want users to mess with it)
[simgrid.git] / org / simgrid / msg / Task.java
index 93b7863..d0b5d03 100644 (file)
@@ -22,8 +22,11 @@ public class Task {
         * a native task. Even if this attribute is public you must never
         * access to it. It is set automatically during the build of the object.
         */
-       public long bind = 0;
-
+       private long bind = 0;
+       /**
+        * Task name
+        */
+       protected String name;
 
        /** Default constructor (all fields to 0 or null) */
        public Task() {
@@ -98,16 +101,19 @@ public class Task {
        /* *                   * *
         * * Getters / Setters * *
         * *                   * */
-    /** Gets the name of a task
-     * FIXME: Cache it.
-     * @return
+    /** 
+     * Gets the name of a task
      */
-       public native String getName();
-       /** Gets the sender of the task */
-       //FIXME: Don't crash when the task has just been created.
+       public String getName() {
+               return name;
+       }
+       /**
+        * Gets the sender of the task 
+        * Returns null if the task hasn't been sent yet
+        */
        public native Process getSender();
-       /** Gets the source of the task
-        * FIXME: Not defensive enough, can crash.
+       /** Gets the source of the task.
+        * Returns null if the task hasn't been sent yet.
      */
        public native Host getSource();   
        /** Gets the computing amount of the task
@@ -117,6 +123,11 @@ public class Task {
        /** Gets the remaining computation of the task
      */
        public native double getRemainingDuration();
+       /**
+        * Sets the name of the task
+        * @param name the new task name.c
+        */
+       public native void setName(String name);
        /**
         * This method sets the priority of the computation of the task.
         * The priority doesn't affect the transfer rate. For example a
@@ -126,11 +137,11 @@ public class Task {
         * @param priority      The new priority of the task.
         */ 
        public native void setPriority(double priority);
-       /* *                       * *
-        * * Communication-related * *
-        * *                       * */
-
-
+       /**
+        * Set the computation amount needed to process the task
+        * @param computationAmount the amount of computation needed to process the task
+        */
+       public native void setComputeDuration(double computationAmount);
        /* *                     * *
         * * Computation-related * *
         * *                     * */
@@ -158,6 +169,9 @@ public class Task {
         * The natively implemented method to destroy a MSG task.
         */
        protected native void destroy();
+       /* *                       * *
+        * * Communication-related * *
+        * *                       * */
 
        /** Send the task asynchronously on the mailbox identified by the specified name, 
         *  with no way to retrieve whether the communication succeeded or not
@@ -172,7 +186,7 @@ public class Task {
         * @throws HostFailureException 
         * @throws TransferFailureException 
         */
-       public void send(String mailbox) throws NativeException, TransferFailureException, HostFailureException, TimeoutException {
+       public void send(String mailbox) throws TransferFailureException, HostFailureException, TimeoutException {
                send(mailbox, -1);
        } 
 
@@ -186,7 +200,7 @@ public class Task {
         * @throws HostFailureException 
         * @throws TransferFailureException 
         */
-       public native void send(String mailbox, double timeout) throws NativeException, TransferFailureException, HostFailureException, TimeoutException;
+       public native void send(String mailbox, double timeout) throws TransferFailureException, HostFailureException, TimeoutException;
        /**
         * Sends the task on the mailbox identified by the specified alias  (capping the sending rate to \a maxrate) 
         *