Task
Date: 2013-11-17

org.simgrid.msg

## Class Task

- java.lang.Object
- - org.simgrid.msg.Task

-     public class Task
      extends java.lang.Object

  A task is either something to compute somewhere, or something to exchange between two hosts (or both). It is defined by a computing amount and a message size.

- - ### Field Summary

    Fields
    Modifier and Type | Field and Description
    --- | ---
    `protected java.lang.String` | `name` Task name

  - ### Constructor Summary

    Constructors
    Constructor and Description
    `Task()` Default constructor (all fields to 0 or null)
    `Task(java.lang.String name, double computeDuration, double messageSize)` Construct an new task with the specified processing amount and amount of data needed.
    `Task(java.lang.String name, Host[] hosts, double[] computeDurations, double[] messageSizes)` Construct an new parallel task with the specified processing amount and amount for each host implied.

  - ### Method Summary

    Methods
    Modifier and Type | Method and Description
    --- | ---
    `void` | `cancel()` Cancels a task.
    `protected void` | `destroy()` The natively implemented method to destroy a MSG task.
    `void` | `dsend(java.lang.String mailbox)` Send the task asynchronously on the mailbox identified by the specified name, with no way to retrieve whether the communication succeeded or not
    `void` | `dsendBounded(java.lang.String mailbox, double maxrate)` Send the task asynchronously on the mailbox identified by the specified name, with no way to retrieve whether the communication succeeded or not
    `void` | `execute()` Executes a task on the location on which the process is running.
    `protected void` | `finalize()` Deletes a task.
    `double` | `getComputeDuration()` Gets the computing amount of the task FIXME: Cache it !
    `java.lang.Long` | `getId()`
    `double` | `getMessageSize()`
    `java.lang.String` | `getName()` Gets the name of a task
    `double` | `getRemainingDuration()` Gets the remaining computation of the task
    `Process` | `getSender()` Gets the sender of the task Returns null if the task hasn't been sent yet
    `Host` | `getSource()` Gets the source of the task.
    `static Comm` | `irecv(java.lang.String mailbox)` Starts listening for receiving a task from an asynchronous communication
    `static Comm` | `irecvBounded(java.lang.String mailbox, double rate)` Starts listening for receiving a task from an asynchronous communication with a capped rate
    `Comm` | `isend(java.lang.String mailbox)` Sends the task on the mailbox asynchronously
    `Comm` | `isendBounded(java.lang.String mailbox, double maxrate)` Sends the task on the mailbox asynchronously (capping the sending rate to \a maxrate)
    `static boolean` | `listen(java.lang.String mailbox)` Listen whether there is a waiting task on the mailbox identified by the specified alias
    `static int` | `listenFrom(java.lang.String mailbox)` Tests whether there is a pending communication on the mailbox identified by the specified alias, and who sent it
    `static int` | `listenFromHost(java.lang.String alias, Host host)` 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.
    `static void` | `nativeInit()` Class initializer, to initialize various JNI stuff
    `static Task` | `receive(java.lang.String mailbox)` Retrieves next task from the mailbox identified by the specified name
    `static Task` | `receive(java.lang.String mailbox, double timeout)` Retrieves next task on the mailbox identified by the specified name (wait at most \a timeout seconds)
    `static Task` | `receive(java.lang.String mailbox, double timeout, Host host)` Retrieves next task sent by a given host on the mailbox identified by the specified alias (wait at most \a timeout seconds)
    `static Task` | `receive(java.lang.String mailbox, Host host)` Retrieves next task sent by a given host on the mailbox identified by the specified alias
    `static Task` | `receiveBounded(java.lang.String mailbox, double rate)` Retrieves next task from the mailbox identified by the specified name with a capped rate
    `static Task` | `receiveBounded(java.lang.String mailbox, double timeout, double rate)` Retrieves next task on the mailbox identified by the specified name (wait at most \a timeout seconds) with a capped rate
    `static Task` | `receiveBounded(java.lang.String mailbox, double timeout, Host host, double rate)` Retrieves next task sent by a given host on the mailbox identified by the specified alias (wait at most \a timeout seconds) with a capped rate
    `static Task` | `receiveBounded(java.lang.String mailbox, Host host, double rate)` Retrieves next task sent by a given host on the mailbox identified by the specified alias with a capped rate
    `void` | `send(java.lang.String mailbox)` Sends the task on the mailbox identified by the specified name
    `void` | `send(java.lang.String mailbox, double timeout)` Sends the task on the mailbox identified by the specified name (wait at most \a timeout seconds)
    `void` | `sendBounded(java.lang.String alias, double maxrate)` Sends the task on the mailbox identified by the specified alias (capping the sending rate to \a maxrate)
    `void` | `sendBounded(java.lang.String alias, double timeout, double maxrate)` Sends the task on the mailbox identified by the specified alias (capping the sending rate to \a maxrate) with a timeout
    `void` | `setComputeDuration(double computationAmount)` Set the computation amount needed to process the task
    `void` | `setDataSize(double dataSize)` Set the data size of the task
    `void` | `setId(java.lang.Long id)`
    `void` | `setName(java.lang.String name)` Sets the name of the task
    `void` | `setPriority(double priority)` This method sets the priority of the computation of the task.

    - ### Methods inherited from class java.lang.Object

      `clone, equals, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait`

- - ### Field Detail

    - #### name

          protected java.lang.String name

      Task name

  - ### Constructor Detail

    - #### Task

          public Task()

      Default constructor (all fields to 0 or null)

    - #### Task

          public Task(java.lang.String name,
              double computeDuration,
              double messageSize)

      Construct an new task with the specified processing amount and amount of data needed.
      Parameters:
        `name` - Task's name
        `computeDuration` - A value of the processing amount (in flop) needed to process the task. If 0, then it cannot be executed with the execute() method. This value has to be >= 0.
        `messageSize` - A value of amount of data (in bytes) needed to transfert this task. If 0, then it cannot be transfered with the get() and put() methods. This value has to be >= 0.

    - #### Task

          public Task(java.lang.String name,
              Host[] hosts,
              double[] computeDurations,
              double[] messageSizes)

      Construct an new parallel task with the specified processing amount and amount for each host implied.
      Parameters:
        `name` - The name of the parallel task.
        `hosts` - The list of hosts implied by the parallel task.
        `computeDurations` - The amount of operations to be performed by each host of \a hosts.
        `messageSizes` - A matrix describing the amount of data to exchange between hosts.

  - ### Method Detail

    - #### getName

          public java.lang.String getName()

      Gets the name of a task

    - #### getSender

          public Process getSender()

      Gets the sender of the task Returns null if the task hasn't been sent yet

    - #### getSource

          public Host getSource()

      Gets the source of the task. Returns null if the task hasn't been sent yet.

    - #### getComputeDuration

          public double getComputeDuration()

      Gets the computing amount of the task FIXME: Cache it !

    - #### getRemainingDuration

          public double getRemainingDuration()

      Gets the remaining computation of the task

    - #### setName

          public void setName(java.lang.String name)

      Sets the name of the task
      Parameters:
        `name` - the new task name.c

    - #### setPriority

          public void setPriority(double priority)

      This method sets the priority of the computation of the task. 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.
      Parameters:
        `priority` - The new priority of the task.

    - #### setComputeDuration

          public void setComputeDuration(double computationAmount)

      Set the computation amount needed to process the task
      Parameters:
        `computationAmount` - the amount of computation needed to process the task

    - #### setDataSize

          public void setDataSize(double dataSize)

      Set the data size of the task
      Parameters:
        `dataSize` - the size of the task

    - #### execute

          public void execute()
                       throws HostFailureException,
                              TaskCancelledException

      Executes a task on the location on which the process is running.
      Throws:
        `HostFailureException`
        `TaskCancelledException`

    - #### cancel

          public void cancel()

      Cancels a task.

    - #### finalize

          protected void finalize()
                           throws NativeException

      Deletes a task.
      Overrides:
        `finalize` in class `java.lang.Object`
      Throws:
        `NativeException` - if the destruction failed.

    - #### destroy

          protected void destroy()

      The natively implemented method to destroy a MSG task.

    - #### dsendBounded

          public void dsendBounded(java.lang.String mailbox,
                          double maxrate)

      Send the task asynchronously on the mailbox identified by the specified name, with no way to retrieve whether the communication succeeded or not

    - #### dsend

          public void dsend(java.lang.String mailbox)

      Send the task asynchronously on the mailbox identified by the specified name, with no way to retrieve whether the communication succeeded or not

    - #### send

          public void send(java.lang.String mailbox)
                    throws TransferFailureException,
                           HostFailureException,
                           TimeoutException

      Sends the task on the mailbox identified by the specified name
      Parameters:
        `mailbox` -
      Throws:
        `TimeoutException`
        `HostFailureException`
        `TransferFailureException`

    - #### send

          public void send(java.lang.String mailbox,
                  double timeout)
                    throws TransferFailureException,
                           HostFailureException,
                           TimeoutException

      Sends the task on the mailbox identified by the specified name (wait at most \a timeout seconds)
      Parameters:
        `mailbox` -
        `timeout` -
      Throws:
        `NativeException` - if the retrieval fails.
        `TimeoutException`
        `HostFailureException`
        `TransferFailureException`

    - #### sendBounded

          public void sendBounded(java.lang.String alias,
                         double maxrate)
                           throws TransferFailureException,
                                  HostFailureException,
                                  TimeoutException

      Sends the task on the mailbox identified by the specified alias (capping the sending rate to \a maxrate)
      Parameters:
        `alias` -
        `maxrate` -
      Throws:
        `TransferFailureException`
        `HostFailureException`
        `TimeoutException`

    - #### sendBounded

          public void sendBounded(java.lang.String alias,
                         double timeout,
                         double maxrate)
                           throws TransferFailureException,
                                  HostFailureException,
                                  TimeoutException

      Sends the task on the mailbox identified by the specified alias (capping the sending rate to \a maxrate) with a timeout
      Parameters:
        `alias` -
        `timeout` -
        `maxrate` -
      Throws:
        `TransferFailureException`
        `HostFailureException`
        `TimeoutException`

    - #### isend

          public Comm isend(java.lang.String mailbox)

      Sends the task on the mailbox asynchronously

    - #### isendBounded

          public Comm isendBounded(java.lang.String mailbox,
                          double maxrate)

      Sends the task on the mailbox asynchronously (capping the sending rate to \a maxrate)

    - #### irecv

          public static Comm irecv(java.lang.String mailbox)

      Starts listening for receiving a task from an asynchronous communication
      Parameters:
        `mailbox` -

    - #### receive

          public static Task receive(java.lang.String mailbox)
                              throws TransferFailureException,
                                     HostFailureException,
                                     TimeoutException

      Retrieves next task from the mailbox identified by the specified name
      Parameters:
        `mailbox` -
      Throws:
        `TransferFailureException`
        `HostFailureException`
        `TimeoutException`

    - #### receive

          public static Task receive(java.lang.String mailbox,
                     double timeout)
                              throws TransferFailureException,
                                     HostFailureException,
                                     TimeoutException

      Retrieves next task on the mailbox identified by the specified name (wait at most \a timeout seconds)
      Parameters:
        `mailbox` -
        `timeout` -
      Throws:
        `TransferFailureException`
        `HostFailureException`
        `TimeoutException`

    - #### receive

          public static Task receive(java.lang.String mailbox,
                     Host host)
                              throws TransferFailureException,
                                     HostFailureException,
                                     TimeoutException

      Retrieves next task sent by a given host on the mailbox identified by the specified alias
      Parameters:
        `mailbox` -
        `host` -
      Throws:
        `TransferFailureException`
        `HostFailureException`
        `TimeoutException`

    - #### receive

          public static Task receive(java.lang.String mailbox,
                     double timeout,
                     Host host)
                              throws TransferFailureException,
                                     HostFailureException,
                                     TimeoutException

      Retrieves next task sent by a given host on the mailbox identified by the specified alias (wait at most \a timeout seconds)
      Parameters:
        `mailbox` -
        `timeout` -
        `host` -
      Throws:
        `TransferFailureException`
        `HostFailureException`
        `TimeoutException`

    - #### irecvBounded

          public static Comm irecvBounded(java.lang.String mailbox,
                          double rate)

      Starts listening for receiving a task from an asynchronous communication with a capped rate
      Parameters:
        `mailbox` -

    - #### receiveBounded

          public static Task receiveBounded(java.lang.String mailbox,
                            double rate)
                                     throws TransferFailureException,
                                            HostFailureException,
                                            TimeoutException

      Retrieves next task from the mailbox identified by the specified name with a capped rate
      Parameters:
        `mailbox` -
      Throws:
        `TransferFailureException`
        `HostFailureException`
        `TimeoutException`

    - #### receiveBounded

          public static Task receiveBounded(java.lang.String mailbox,
                            double timeout,
                            double rate)
                                     throws TransferFailureException,
                                            HostFailureException,
                                            TimeoutException

      Retrieves next task on the mailbox identified by the specified name (wait at most \a timeout seconds) with a capped rate
      Parameters:
        `mailbox` -
        `timeout` -
      Throws:
        `TransferFailureException`
        `HostFailureException`
        `TimeoutException`

    - #### receiveBounded

          public static Task receiveBounded(java.lang.String mailbox,
                            Host host,
                            double rate)
                                     throws TransferFailureException,
                                            HostFailureException,
                                            TimeoutException

      Retrieves next task sent by a given host on the mailbox identified by the specified alias with a capped rate
      Parameters:
        `mailbox` -
        `host` -
      Throws:
        `TransferFailureException`
        `HostFailureException`
        `TimeoutException`

    - #### receiveBounded

          public static Task receiveBounded(java.lang.String mailbox,
                            double timeout,
                            Host host,
                            double rate)
                                     throws TransferFailureException,
                                            HostFailureException,
                                            TimeoutException

      Retrieves next task sent by a given host on the mailbox identified by the specified alias (wait at most \a timeout seconds) with a capped rate
      Parameters:
        `mailbox` -
        `timeout` -
        `host` -
      Throws:
        `TransferFailureException`
        `HostFailureException`
        `TimeoutException`

    - #### listenFrom

          public static int listenFrom(java.lang.String mailbox)

      Tests whether there is a pending communication on the mailbox identified by the specified alias, and who sent it

    - #### listen

          public static boolean listen(java.lang.String mailbox)

      Listen whether there is a waiting task on the mailbox identified by the specified alias

    - #### listenFromHost

          public static int listenFromHost(java.lang.String alias,
                           Host host)

      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.

    - #### nativeInit

          public static void nativeInit()

      Class initializer, to initialize various JNI stuff

    - #### getMessageSize

          public double getMessageSize()

    - #### getId

          public java.lang.Long getId()

    - #### setId

          public void setId(java.lang.Long id)