-/*\r
- * Task.hpp\r
- *\r
- * This file contains the declaration of the wrapper class of the native MSG task type.\r
- *\r
- * Copyright 2006,2007 Martin Quinson, Malek Cherier \r
- * All right reserved. \r
- *\r
- * This program is free software; you can redistribute \r
- * it and/or modify it under the terms of the license \r
- *(GNU LGPL) which comes with this package. \r
- *\r
- */ \r
- \r
-#ifndef MSG_TASK_HPP\r
-#define MSG_TASK_HPP\r
-\r
-// Compilation C++ recquise\r
-#ifndef __cplusplus\r
- #error Task.hpp requires C++ compilation (use a .cxx suffix)\r
-#endif\r
-\r
-#include <msg/datatypes.h>\r
-\r
-#include <MsgException.hpp>\r
-#include <InvalidArgumentException.hpp>\r
-#include <NullPointerException.hpp>\r
-#include <MsgException.hpp>\r
-#include <BadAllocException.hpp>\r
-\r
-#include <Object.hpp>\r
-\r
-namespace SimGrid\r
-{\r
- namespace Msg\r
- {\r
- class Process;\r
- class Host;\r
-\r
- // SimGrid::Msg::Task wrapper class declaration.\r
- class SIMGRIDX_EXPORT Task : public Object\r
- {\r
- MSG_DECLARE_DYNAMIC(Task);\r
-\r
- friend class Process;\r
- friend class Host;\r
-\r
- protected:\r
- // Default constructor.\r
- Task();\r
- \r
- public:\r
- /*! \brief Copy constructor.\r
- */\r
- Task(const Task& rTask);\r
- \r
- /*! \brief Destructor.\r
- *\r
- * \exception If the destructor failed, it throw the exception described below:\r
- *\r
- * [MsgException] if a native exception occurs.\r
- */\r
- virtual ~Task()\r
- throw(MsgException);\r
- \r
- /*! \brief Constructs an new task with the specified processing amount and amount\r
- * of data needed.\r
- *\r
- * \param name Task's name\r
- * \param computeDuration A value of the processing amount (in flop) needed to process the task. \r
- * If 0, then it cannot be executed with the execute() method.\r
- * This value has to be >= 0.\r
- * \param messageSize A value of amount of data (in bytes) needed to transfert this task.\r
- * If 0, then it cannot be transfered with the get() and put() methods.\r
- * This value has to be >= 0.\r
- *\r
- * \exception If this method failed, it throws one of the exceptions described below:\r
- *\r
- * [InvalidArgumentException] if the parameter computeDuration or messageSize\r
- * is negative.\r
- * [NullPointerException] if the parameter name is NULL.\r
- *\r
- * [MsgException] if a internal exception occurs.\r
- */\r
- Task(const char* name, double computeDuration, double messageSize)\r
- throw (InvalidArgumentException, NullPointerException);\r
- \r
- /*! \Constructs an new parallel task with the specified processing amount and amount for each host\r
- * implied.\r
- *\r
- * \param name The name of the parallel task.\r
- * \param hosts The list of hosts implied by the parallel task.\r
- * \param computeDurations The amount of operations to be performed by each host of \a hosts.\r
- * \param messageSizes A matrix describing the amount of data to exchange between hosts.\r
- * \hostCount The number of hosts implied in the parallel task.\r
- * \r
- * \exception If this method fails, it throws one of the exceptions described below:\r
- *\r
- * [NullPointerException] if the parameter name is NULL or\r
- * if the parameter computeDurations is NULL or\r
- * if the parameter messageSizes is NULL\r
- *\r
- * [InvalidArgumentException] if the parameter hostCount is negative or zero. \r
- */\r
- Task(const char* name, Host* hosts, double* computeDurations, double* messageSizes, int hostCount)\r
- throw(NullPointerException, InvalidArgumentException);\r
- \r
- \r
- /*! \brief Task::getName() - Gets the names of the task.\r
- *\r
- * \return The name of the task.\r
- */\r
- const char* getName(void) const;\r
- \r
- /*! \brief Task::getSender() - Gets the sender of the task.\r
- *\r
- * \return A reference to the sender of the task.\r
- */\r
- Process& getSender(void) const;\r
- \r
- /*! \brief Task::getSource() - Gets the source of the task.\r
- * \r
- * \return A reference to the source of the task.\r
- */\r
- Host& getSource(void) const;\r
- \r
- /*! \brief Task::getComputeDuration() - Get the computing amount of the task.\r
- *\r
- * \return The computing amount of the task.\r
- */\r
- \r
- double getComputeDuration(void) const;\r
- \r
- /*! \brief Task::getRemainingDuration() - Gets the remaining computation.\r
- *\r
- * \return The remining computation of the task.\r
- */\r
- double getRemainingDuration(void) const;\r
- \r
- /*! \brief Task::setPrirority() - Sets the priority of the computation of the task.\r
- * The priority doesn't affect the transfert rate. For example a\r
- * priority of 2 will make the task receive two times more cpu than\r
- * the other ones.\r
- *\r
- * \param priority The new priority of the task.\r
- *\r
- * execption If this method fails, it throws the exception described below:\r
- *\r
- * [InvalidArgumentException] if the parameter priority is negative.\r
- */\r
- void setPriority(double priority)\r
- throw(InvalidArgumentException);\r
- \r
- /*! \brief Task::get() - Gets a task from the specified channel of the host of the current process.\r
- *\r
- * \param channel The channel number to get the task.\r
- *\r
- * \return If successful the method returns the task. Otherwise the method throws one\r
- * of the exceptions described below:\r
- *\r
- * \exception [InvalidArgumentException] if the channel parameter is negative.\r
- * \r
- * [MsgException] if an internal excpetion occurs.\r
- */\r
- static Task* get(int channel) \r
- throw(InvalidArgumentException, MsgException);\r
-\r
- /*! \brief Task::get() - Gets a task from the given channel number of the given host. \r
- *\r
- * \param channel The channel number.\r
- * \param rHost A reference of the host owning the channel.\r
- *\r
- * \return If successful, the method returns the task. Otherwise the method\r
- * throw one of the exceptions described below:\r
- *\r
- * \exception [InvalidArgumentException] if the channel number is negative.\r
- *\r
- * [MsgException] if an internal exception occurs.\r
- */\r
- static Task* get(int channel, const Host& rHost) \r
- throw(InvalidArgumentException, MsgException);\r
- \r
- /*! \brief Task::get() - Gets a task from the specified channel of the specified host\r
- * (waiting at most given time).\r
- *\r
- * \param channel The channel number.\r
- * \param timeout The timeout value.\r
- * \param rHost A reference to the host owning the channel.\r
- *\r
- * \return If successful, the method returns the task. Otherwise the method returns\r
- * one of the exceptions described below:\r
- *\r
- * \exception [InvalidArgumentException] if the channel number is negative or\r
- * if the timeout value is negative and \r
- * different than -1.0.\r
- * [MsgException] if an internal exception occurs.\r
- */\r
- static Task* get(int channel, double timeout, const Host& rHost) \r
- throw(InvalidArgumentException, MsgException); \r
- \r
- /*! \brief Task::probe() - Probes whether there is a waiting task on the given channel of local host.\r
- *\r
- * \param channel The channel number.\r
- *\r
- * \return If there is a waiting task on the channel the method returns 1. Otherwise\r
- * the method returns 0.\r
- *\r
- * \exception If this method fails, it throws the exception described below:\r
- *\r
- * [InvalidArgumentException] if the parameter channel is negative.\r
- */\r
- static int probe(int channel)\r
- throw(InvalidArgumentException);\r
- \r
- /*! \brief Task::probe() - Counts tasks waiting on the given channel of local host and sent by given host.\r
- *\r
- * \param channel The channel id.\r
- * \param rHost A reference to the host that has sent the task.\r
- *\r
- * \return The number of tasks.\r
- *\r
- * \exception [InvalidArgumentException] if the parameter channel is negative.\r
- */\r
- static int probe(int channel, const Host& rHost)\r
- throw(InvalidArgumentException);\r
- \r
- /*! \brief Task::execute() - This method executes a task on the location on which the\r
- * process is running.\r
- *\r
- * \exception If this method fails, it returns the exception described below:\r
- *\r
- * [MsgException] if an internal exception occurs.\r
- */\r
- void execute(void) \r
- throw(MsgException);\r
- \r
- /*! \brief Task::cancel() - This method cancels a task.\r
- *\r
- * \exception If this method fails, it returns the exception described below:\r
- *\r
- * [MsgException] if an internal exception occurs.\r
- */\r
- void cancel(void) \r
- throw(MsgException);\r
- \r
- /*! \brief Task::send() - Send the task on the mailbox identified by the default alias.\r
- *\r
- * \exception If this method failed, it returns one of the exceptions described\r
- * below:\r
- *\r
- * [BadAllocException] if there is not enough memory to build the default alias.\r
- *\r
- * [MsgException] if an internal exception occurs.\r
- */\r
- void send(void) \r
- throw(BadAllocException, MsgException);\r
- \r
- /*! \brief Task::send() - Send the task on the mailbox identified by the given alias.\r
- *\r
- * \param alias The alias of the mailbox where to send the task.\r
- *\r
- * \exception If this method failed, it returns one of the exceptions described\r
- * below:\r
- *\r
- * [NullPointerException] if there parameter alias is NULL.\r
- *\r
- * [MsgException] if an internal exception occurs.\r
- */ \r
- void send(const char* alias) \r
- throw(NullPointerException, MsgException);\r
- \r
- /*! \brief Task::send() - Send the task on the mailbox identified by the default alias\r
- * (waiting at most given time).\r
- *\r
- * \param timeout The timeout value.\r
- *\r
- * \exception If this method failed, it returns one of the exceptions described\r
- * below:\r
- *\r
- * [BadAllocException] if there is not enough memory to build the default alias.\r
- *\r
- * [InvalidArgumentException] if the timeout value is negative or different -1.0.\r
- *\r
- * [MsgException] if an internal exception occurs.\r
- */\r
- void send(double timeout) \r
- throw(BadAllocException, InvalidArgumentException, MsgException);\r
- \r
- /*! \brief Task::send() - Send the task on the mailbox identified by a given alias\r
- * (waiting at most given time).\r
- *\r
- * \param alias The alias of the mailbox where to send the task.\r
- * \param timeout The timeout value.\r
- *\r
- * \exception If this method failed, it returns one of the exceptions described\r
- * below:\r
- *\r
- * [NullPointerException] if alias parameter is NULL.\r
- *\r
- * [InvalidArgumentException] if the timeout value is negative or different -1.0.\r
- *\r
- * [MsgException] if an internal exception occurs.\r
- */\r
- void send(const char* alias, double timeout) \r
- throw(NullPointerException, InvalidArgumentException, MsgException);\r
- \r
- /*! \brief Task::sendBounded() - Sends the task on the mailbox identified by the default alias.\r
- * (capping the emision rate to maxrate).\r
- *\r
- * \param maxRate The maximum rate value.\r
- *\r
- * \exception If this method failed, it throws one of the exceptions described below:\r
- *\r
- * [BadAllocException] if there is not enough memory to build the default alias.\r
- *\r
- * [InvalidArgumentException] if the parameter maxRate is negative and different\r
- * than -1.0.\r
- *\r
- * [MsgException] if an internal exception occurs.\r
- */\r
- void sendBounded(double maxRate) \r
- throw(BadAllocException, InvalidArgumentException, MsgException);\r
- \r
- /*! \brief Task::sendBounded() - Sends the task on the mailbox identified by the given alias.\r
- * (capping the emision rate to maxrate).\r
- *\r
- *\ param alias The alias of the mailbox where to send the task.\r
- * \param maxRate The maximum rate value.\r
- *\r
- * \exception If this method failed, it throws one of the exceptions described below:\r
- *\r
- * [NullPointerException] if the alias parameter is NULL.\r
- *\r
- * [InvalidArgumentException] if the parameter maxRate is negative and different\r
- * than -1.0.\r
- *\r
- * [MsgException] if an internal exception occurs.\r
- */\r
- void sendBounded(const char* alias, double maxRate) \r
- throw(NullPointerException, InvalidArgumentException, MsgException);\r
- \r
- \r
- /*! \brief Task::receive() - Receives a task from the mailbox identified by the default alias (located\r
- * on the local host).\r
- *\r
- * \return A reference to the task.\r
- *\r
- * \exception If this method failed, it throws one of the exception described below:\r
- *\r
- * [BadAllocException] if there is not enough memory to build the default alias.\r
- *\r
- * [MsgException] if an internal exception occurs.\r
- */\r
- /*static Task& receive(void) \r
- throw(BadAllocException, MsgException);*/\r
-\r
- static Task* receive(void) \r
- throw(BadAllocException, MsgException);\r
- \r
- /*! \brief Task::receive() - Receives a task from the mailbox identified by a given alias (located\r
- * on the local host).\r
- *\r
- * \alias The alias of the mailbox.\r
- *\r
- * \return A reference to the task.\r
- *\r
- * \exception If this method failed, it throws one of the exception described below:\r
- *\r
- * [NullPointerException] if the alias parameter is NULL.\r
- *\r
- * [MsgException] if an internal exception occurs.\r
- */\r
- /*static Task& receive(const char* alias) \r
- throw(NullPointerException, MsgException);*/\r
- static Task* receive(const char* alias) \r
- throw(NullPointerException, MsgException);\r
- \r
- /*! \brief Task::receive() - Receives a task from the mailbox identified by a given alias (located\r
- * on the local host and waiting at most given time).\r
- *\r
- * \alias The alias of the mailbox.\r
- * \timeout The timeout value.\r
- *\r
- * \return A reference to the task.\r
- *\r
- * \exception If this method failed, it throws one of the exception described below:\r
- *\r
- * [NullPointerException] if the alias parameter is NULL.\r
- *\r
- * [InvalidArgumentException] if the timeout value is negatif and different than\r
- * -1.0.\r
- *\r
- * [MsgException] if an internal exception occurs.\r
- */\r
- static Task* receive(const char* alias, double timeout) \r
- throw(NullPointerException, InvalidArgumentException, MsgException);\r
- \r
- /*! \brief Task::receive() - Receives a task from the mailbox identified by a given alias located\r
- * on the given host.\r
- *\r
- * \alias The alias of the mailbox.\r
- * \rHost The location of the mailbox.\r
- *\r
- * \return A reference to the task.\r
- *\r
- * \exception If this method failed, it throws one of the exception described below:\r
- *\r
- * [NullPointerException] if the alias parameter is NULL.\r
- *\r
- * [MsgException] if an internal exception occurs.\r
- */\r
- static Task* receive(const char* alias, const Host& rHost) \r
- throw(NullPointerException, MsgException);\r
- \r
- /*! \brief Task::receive() - Receives a task from the mailbox identified by a given alias located\r
- * on the given host (and waiting at most given time).\r
- *\r
- * \alias The alias of the mailbox.\r
- * \timeout The timeout value.\r
- * \rHost The location of the mailbox.\r
- *\r
- * \return A reference to the task.\r
- *\r
- * \exception If this method failed, it throws one of the exception described below:\r
- *\r
- * [NullPointerException] if the alias parameter is NULL.\r
- *\r
- * [InvalidArgumentException] if the timeout value is negatif and different than\r
- * -1.0.\r
- *\r
- * [MsgException] if an internal exception occurs.\r
- */\r
- static Task* receive(const char* alias, double timeout, const Host& rHost) \r
- throw(NullPointerException, InvalidArgumentException, MsgException);\r
- \r
- /*! \brief Task::listen() - Listen whether there is a waiting task on the mailbox \r
- * identified by the default alias of local host.\r
- *\r
- * \return If there is a waiting task on the mailbox the method returns true.\r
- * Otherwise the method returns false.\r
- *\r
- * \exception If this method fails, it throws one of the exceptions described below:\r
- *\r
- * [BadAllocException] if there is not enough memory to build the default alias.\r
- */\r
- static int listen(void) \r
- throw(BadAllocException);\r
- \r
- /*! \brief Task::listen() - Listen whether there is a waiting task on the mailbox \r
- * identified by the given alias of local host.\r
- *\r
- * \param alias The alias of the mailbox.\r
- *\r
- * \return If there is a waiting task on the mailbox the method returns 1.\r
- * Otherwise the method returns 0.\r
- *\r
- * \exception If this method fails, it throws one of the exceptions described below:\r
- *\r
- * [NullPointerException] if the parameter alias is NULL.\r
- */\r
- static int listen(const char* alias) \r
- throw(NullPointerException);\r
- \r
- /*! \brief Task::listenFrom() - Tests whether there is a pending communication on the mailbox \r
- * identified by the default alias, and who sent it.\r
- *\r
- * \return If there is a pending communication on the mailbox, the method returns\r
- * the PID of it sender. Otherwise the method returns -1.\r
- *\r
- * \exception If this method fails, it throws the exception described below:\r
- *\r
- * [BadAllocException] if there is not enough memory to build the default\r
- * alias.\r
- */\r
- static int listenFrom(void) \r
- throw(BadAllocException);\r
- \r
- /*! \brief Task::listenFrom() - Tests whether there is a pending communication on the mailbox \r
- * identified by the specified alias, and who sent it.\r
- *\r
- * \alias The alias of the mailbox.\r
- *\r
- * \return If there is a pending communication on the mailbox, the method returns\r
- * the PID of it sender. Otherwise the method returns -1.\r
- *\r
- * \exception If this method fails, it throws the exception described below:\r
- *\r
- * [NullPointerException] if the alias parameter is NULL.\r
- */\r
- static int listenFrom(const char* alias) \r
- throw(NullPointerException);\r
- \r
- /*! \brief Task::listenFromHost() - Tests whether there is a pending communication on the mailbox \r
- * identified by the default alias and located on the host of the current process, and who sent it.\r
- *\r
- * \param rHost The location of the mailbox.\r
- *\r
- * \return If there is a pending communication on the mailbox, the method returns\r
- * the PID of it sender. Otherwise the method returns -1.\r
- *\r
- * \exception If this method fails, it throws the exception described below:\r
- *\r
- * [BadAllocException] if there is not enough memory to build the default\r
- * alias.\r
- */\r
- static int listenFromHost(const Host& rHost) \r
- throw(BadAllocException);\r
- \r
- /*! \brief Task::listenFromHost() - Tests whether there is a pending communication on the mailbox \r
- * identified by the default alias and located on the host of the current process, and who sent it.\r
- *\r
- * \param rHost The location of the mailbox.\r
- *\r
- * \return If there is a pending communication on the mailbox, the method returns\r
- * the PID of it sender. Otherwise the method returns -1.\r
- *\r
- * \exception If this method fails, it throws the exception described below:\r
- *\r
- * [BadAllocException] if there is not enough memory to build the default\r
- * alias.\r
- */\r
- static int listenFromHost(const char* alias, const Host& rHost) \r
- throw(NullPointerException);\r
-\r
- virtual const Task& operator= (const Task& rTask);\r
- \r
- protected:\r
- \r
- // Attributes.\r
- \r
- m_task_t nativeTask; // the native MSG task.\r
- };\r
- \r
- } // namespace Msg \r
-} // namespace SimGrid\r
-\r
-typedef Task* TaskPtr;\r
-\r
-#endif // §MSG_TASK_HPP\r
-\r
+/*
+ * Task.hpp
+ *
+ * This file contains the declaration of the wrapper class of the native MSG task type.
+ *
+ * Copyright 2006,2007 Martin Quinson, Malek Cherier
+ * All right reserved.
+ *
+ * This program is free software; you can redistribute
+ * it and/or modify it under the terms of the license
+ *(GNU LGPL) which comes with this package.
+ *
+ */
+
+#ifndef MSG_TASK_HPP
+#define MSG_TASK_HPP
+
+// Compilation C++ recquise
+#ifndef __cplusplus
+ #error Task.hpp requires C++ compilation (use a .cxx suffix)
+#endif
+
+#include <msg/datatypes.h>
+
+#include <MsgException.hpp>
+#include <InvalidArgumentException.hpp>
+#include <NullPointerException.hpp>
+#include <MsgException.hpp>
+#include <BadAllocException.hpp>
+
+#include <Object.hpp>
+
+namespace SimGrid
+{
+ namespace Msg
+ {
+ class Process;
+ class Host;
+
+ // SimGrid::Msg::Task wrapper class declaration.
+ class SIMGRIDX_EXPORT Task : public Object
+ {
+ MSG_DECLARE_DYNAMIC(Task);
+
+ friend class Process;
+ friend class Host;
+
+ protected:
+ // Default constructor.
+ Task();
+
+ public:
+ /*! \brief Copy constructor.
+ */
+ Task(const Task& rTask);
+
+ /*! \brief Destructor.
+ *
+ * \exception If the destructor failed, it throw the exception described below:
+ *
+ * [MsgException] if a native exception occurs.
+ */
+ virtual ~Task()
+ throw(MsgException);
+
+ /*! \brief Constructs an new task with the specified processing amount and amount
+ * of data needed.
+ *
+ * \param name Task's name
+ * \param 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.
+ * \param 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.
+ *
+ * \exception If this method failed, it throws one of the exceptions described below:
+ *
+ * [InvalidArgumentException] if the parameter computeDuration or messageSize
+ * is negative.
+ * [NullPointerException] if the parameter name is NULL.
+ *
+ * [MsgException] if a internal exception occurs.
+ */
+ Task(const char* name, double computeDuration, double messageSize)
+ throw (InvalidArgumentException, NullPointerException);
+
+ /*! \Constructs an new parallel task with the specified processing amount and amount for each host
+ * implied.
+ *
+ * \param name The name of the parallel task.
+ * \param hosts The list of hosts implied by the parallel task.
+ * \param computeDurations The amount of operations to be performed by each host of \a hosts.
+ * \param messageSizes A matrix describing the amount of data to exchange between hosts.
+ * \hostCount The number of hosts implied in the parallel task.
+ *
+ * \exception If this method fails, it throws one of the exceptions described below:
+ *
+ * [NullPointerException] if the parameter name is NULL or
+ * if the parameter computeDurations is NULL or
+ * if the parameter messageSizes is NULL
+ *
+ * [InvalidArgumentException] if the parameter hostCount is negative or zero.
+ */
+ Task(const char* name, Host* hosts, double* computeDurations, double* messageSizes, int hostCount)
+ throw(NullPointerException, InvalidArgumentException);
+
+
+ /*! \brief Task::getName() - Gets the names of the task.
+ *
+ * \return The name of the task.
+ */
+ const char* getName(void) const;
+
+ /*! \brief Task::getSender() - Gets the sender of the task.
+ *
+ * \return A reference to the sender of the task.
+ */
+ Process& getSender(void) const;
+
+ /*! \brief Task::getSource() - Gets the source of the task.
+ *
+ * \return A reference to the source of the task.
+ */
+ Host& getSource(void) const;
+
+ /*! \brief Task::getComputeDuration() - Get the computing amount of the task.
+ *
+ * \return The computing amount of the task.
+ */
+
+ double getComputeDuration(void) const;
+
+ /*! \brief Task::getRemainingDuration() - Gets the remaining computation.
+ *
+ * \return The remining computation of the task.
+ */
+ double getRemainingDuration(void) const;
+
+ /*! \brief Task::setPrirority() - Sets the priority of the computation of the task.
+ * The priority doesn't affect the transfert rate. For example a
+ * priority of 2 will make the task receive two times more cpu than
+ * the other ones.
+ *
+ * \param priority The new priority of the task.
+ *
+ * execption If this method fails, it throws the exception described below:
+ *
+ * [InvalidArgumentException] if the parameter priority is negative.
+ */
+ void setPriority(double priority)
+ throw(InvalidArgumentException);
+
+ /*! \brief Task::get() - Gets a task from the specified channel of the host of the current process.
+ *
+ * \param channel The channel number to get the task.
+ *
+ * \return If successful the method returns the task. Otherwise the method throws one
+ * of the exceptions described below:
+ *
+ * \exception [InvalidArgumentException] if the channel parameter is negative.
+ *
+ * [MsgException] if an internal excpetion occurs.
+ */
+ static Task* get(int channel)
+ throw(InvalidArgumentException, MsgException);
+
+ /*! \brief Task::get() - Gets a task from the given channel number of the given host.
+ *
+ * \param channel The channel number.
+ * \param rHost A reference of the host owning the channel.
+ *
+ * \return If successful, the method returns the task. Otherwise the method
+ * throw one of the exceptions described below:
+ *
+ * \exception [InvalidArgumentException] if the channel number is negative.
+ *
+ * [MsgException] if an internal exception occurs.
+ */
+ static Task* get(int channel, const Host& rHost)
+ throw(InvalidArgumentException, MsgException);
+
+ /*! \brief Task::get() - Gets a task from the specified channel of the specified host
+ * (waiting at most given time).
+ *
+ * \param channel The channel number.
+ * \param timeout The timeout value.
+ * \param rHost A reference to the host owning the channel.
+ *
+ * \return If successful, the method returns the task. Otherwise the method returns
+ * one of the exceptions described below:
+ *
+ * \exception [InvalidArgumentException] if the channel number is negative or
+ * if the timeout value is negative and
+ * different than -1.0.
+ * [MsgException] if an internal exception occurs.
+ */
+ static Task* get(int channel, double timeout, const Host& rHost)
+ throw(InvalidArgumentException, MsgException);
+
+ /*! \brief Task::probe() - Probes whether there is a waiting task on the given channel of local host.
+ *
+ * \param channel The channel number.
+ *
+ * \return If there is a waiting task on the channel the method returns 1. Otherwise
+ * the method returns 0.
+ *
+ * \exception If this method fails, it throws the exception described below:
+ *
+ * [InvalidArgumentException] if the parameter channel is negative.
+ */
+ static int probe(int channel)
+ throw(InvalidArgumentException);
+
+ /*! \brief Task::probe() - Counts tasks waiting on the given channel of local host and sent by given host.
+ *
+ * \param channel The channel id.
+ * \param rHost A reference to the host that has sent the task.
+ *
+ * \return The number of tasks.
+ *
+ * \exception [InvalidArgumentException] if the parameter channel is negative.
+ */
+ static int probe(int channel, const Host& rHost)
+ throw(InvalidArgumentException);
+
+ /*! \brief Task::execute() - This method executes a task on the location on which the
+ * process is running.
+ *
+ * \exception If this method fails, it returns the exception described below:
+ *
+ * [MsgException] if an internal exception occurs.
+ */
+ void execute(void)
+ throw(MsgException);
+
+ /*! \brief Task::cancel() - This method cancels a task.
+ *
+ * \exception If this method fails, it returns the exception described below:
+ *
+ * [MsgException] if an internal exception occurs.
+ */
+ void cancel(void)
+ throw(MsgException);
+
+ /*! \brief Task::send() - Send the task on the mailbox identified by the default alias.
+ *
+ * \exception If this method failed, it returns one of the exceptions described
+ * below:
+ *
+ * [BadAllocException] if there is not enough memory to build the default alias.
+ *
+ * [MsgException] if an internal exception occurs.
+ */
+ void send(void)
+ throw(BadAllocException, MsgException);
+
+ /*! \brief Task::send() - Send the task on the mailbox identified by the given alias.
+ *
+ * \param alias The alias of the mailbox where to send the task.
+ *
+ * \exception If this method failed, it returns one of the exceptions described
+ * below:
+ *
+ * [NullPointerException] if there parameter alias is NULL.
+ *
+ * [MsgException] if an internal exception occurs.
+ */
+ void send(const char* alias)
+ throw(NullPointerException, MsgException);
+
+ /*! \brief Task::send() - Send the task on the mailbox identified by the default alias
+ * (waiting at most given time).
+ *
+ * \param timeout The timeout value.
+ *
+ * \exception If this method failed, it returns one of the exceptions described
+ * below:
+ *
+ * [BadAllocException] if there is not enough memory to build the default alias.
+ *
+ * [InvalidArgumentException] if the timeout value is negative or different -1.0.
+ *
+ * [MsgException] if an internal exception occurs.
+ */
+ void send(double timeout)
+ throw(BadAllocException, InvalidArgumentException, MsgException);
+
+ /*! \brief Task::send() - Send the task on the mailbox identified by a given alias
+ * (waiting at most given time).
+ *
+ * \param alias The alias of the mailbox where to send the task.
+ * \param timeout The timeout value.
+ *
+ * \exception If this method failed, it returns one of the exceptions described
+ * below:
+ *
+ * [NullPointerException] if alias parameter is NULL.
+ *
+ * [InvalidArgumentException] if the timeout value is negative or different -1.0.
+ *
+ * [MsgException] if an internal exception occurs.
+ */
+ void send(const char* alias, double timeout)
+ throw(NullPointerException, InvalidArgumentException, MsgException);
+
+ /*! \brief Task::sendBounded() - Sends the task on the mailbox identified by the default alias.
+ * (capping the emision rate to maxrate).
+ *
+ * \param maxRate The maximum rate value.
+ *
+ * \exception If this method failed, it throws one of the exceptions described below:
+ *
+ * [BadAllocException] if there is not enough memory to build the default alias.
+ *
+ * [InvalidArgumentException] if the parameter maxRate is negative and different
+ * than -1.0.
+ *
+ * [MsgException] if an internal exception occurs.
+ */
+ void sendBounded(double maxRate)
+ throw(BadAllocException, InvalidArgumentException, MsgException);
+
+ /*! \brief Task::sendBounded() - Sends the task on the mailbox identified by the given alias.
+ * (capping the emision rate to maxrate).
+ *
+ *\ param alias The alias of the mailbox where to send the task.
+ * \param maxRate The maximum rate value.
+ *
+ * \exception If this method failed, it throws one of the exceptions described below:
+ *
+ * [NullPointerException] if the alias parameter is NULL.
+ *
+ * [InvalidArgumentException] if the parameter maxRate is negative and different
+ * than -1.0.
+ *
+ * [MsgException] if an internal exception occurs.
+ */
+ void sendBounded(const char* alias, double maxRate)
+ throw(NullPointerException, InvalidArgumentException, MsgException);
+
+
+ /*! \brief Task::receive() - Receives a task from the mailbox identified by the default alias (located
+ * on the local host).
+ *
+ * \return A reference to the task.
+ *
+ * \exception If this method failed, it throws one of the exception described below:
+ *
+ * [BadAllocException] if there is not enough memory to build the default alias.
+ *
+ * [MsgException] if an internal exception occurs.
+ */
+ /*static Task& receive(void)
+ throw(BadAllocException, MsgException);*/
+
+ static Task* receive(void)
+ throw(BadAllocException, MsgException);
+
+ /*! \brief Task::receive() - Receives a task from the mailbox identified by a given alias (located
+ * on the local host).
+ *
+ * \alias The alias of the mailbox.
+ *
+ * \return A reference to the task.
+ *
+ * \exception If this method failed, it throws one of the exception described below:
+ *
+ * [NullPointerException] if the alias parameter is NULL.
+ *
+ * [MsgException] if an internal exception occurs.
+ */
+ /*static Task& receive(const char* alias)
+ throw(NullPointerException, MsgException);*/
+ static Task* receive(const char* alias)
+ throw(NullPointerException, MsgException);
+
+ /*! \brief Task::receive() - Receives a task from the mailbox identified by a given alias (located
+ * on the local host and waiting at most given time).
+ *
+ * \alias The alias of the mailbox.
+ * \timeout The timeout value.
+ *
+ * \return A reference to the task.
+ *
+ * \exception If this method failed, it throws one of the exception described below:
+ *
+ * [NullPointerException] if the alias parameter is NULL.
+ *
+ * [InvalidArgumentException] if the timeout value is negatif and different than
+ * -1.0.
+ *
+ * [MsgException] if an internal exception occurs.
+ */
+ static Task* receive(const char* alias, double timeout)
+ throw(NullPointerException, InvalidArgumentException, MsgException);
+
+ /*! \brief Task::receive() - Receives a task from the mailbox identified by a given alias located
+ * on the given host.
+ *
+ * \alias The alias of the mailbox.
+ * \rHost The location of the mailbox.
+ *
+ * \return A reference to the task.
+ *
+ * \exception If this method failed, it throws one of the exception described below:
+ *
+ * [NullPointerException] if the alias parameter is NULL.
+ *
+ * [MsgException] if an internal exception occurs.
+ */
+ static Task* receive(const char* alias, const Host& rHost)
+ throw(NullPointerException, MsgException);
+
+ /*! \brief Task::receive() - Receives a task from the mailbox identified by a given alias located
+ * on the given host (and waiting at most given time).
+ *
+ * \alias The alias of the mailbox.
+ * \timeout The timeout value.
+ * \rHost The location of the mailbox.
+ *
+ * \return A reference to the task.
+ *
+ * \exception If this method failed, it throws one of the exception described below:
+ *
+ * [NullPointerException] if the alias parameter is NULL.
+ *
+ * [InvalidArgumentException] if the timeout value is negatif and different than
+ * -1.0.
+ *
+ * [MsgException] if an internal exception occurs.
+ */
+ static Task* receive(const char* alias, double timeout, const Host& rHost)
+ throw(NullPointerException, InvalidArgumentException, MsgException);
+
+ /*! \brief Task::listen() - Listen whether there is a waiting task on the mailbox
+ * identified by the default alias of local host.
+ *
+ * \return If there is a waiting task on the mailbox the method returns true.
+ * Otherwise the method returns false.
+ *
+ * \exception If this method fails, it throws one of the exceptions described below:
+ *
+ * [BadAllocException] if there is not enough memory to build the default alias.
+ */
+ static int listen(void)
+ throw(BadAllocException);
+
+ /*! \brief Task::listen() - Listen whether there is a waiting task on the mailbox
+ * identified by the given alias of local host.
+ *
+ * \param alias The alias of the mailbox.
+ *
+ * \return If there is a waiting task on the mailbox the method returns 1.
+ * Otherwise the method returns 0.
+ *
+ * \exception If this method fails, it throws one of the exceptions described below:
+ *
+ * [NullPointerException] if the parameter alias is NULL.
+ */
+ static int listen(const char* alias)
+ throw(NullPointerException);
+
+ /*! \brief Task::listenFrom() - Tests whether there is a pending communication on the mailbox
+ * identified by the default alias, and who sent it.
+ *
+ * \return If there is a pending communication on the mailbox, the method returns
+ * the PID of it sender. Otherwise the method returns -1.
+ *
+ * \exception If this method fails, it throws the exception described below:
+ *
+ * [BadAllocException] if there is not enough memory to build the default
+ * alias.
+ */
+ static int listenFrom(void)
+ throw(BadAllocException);
+
+ /*! \brief Task::listenFrom() - Tests whether there is a pending communication on the mailbox
+ * identified by the specified alias, and who sent it.
+ *
+ * \alias The alias of the mailbox.
+ *
+ * \return If there is a pending communication on the mailbox, the method returns
+ * the PID of it sender. Otherwise the method returns -1.
+ *
+ * \exception If this method fails, it throws the exception described below:
+ *
+ * [NullPointerException] if the alias parameter is NULL.
+ */
+ static int listenFrom(const char* alias)
+ throw(NullPointerException);
+
+ /*! \brief Task::listenFromHost() - Tests whether there is a pending communication on the mailbox
+ * identified by the default alias and located on the host of the current process, and who sent it.
+ *
+ * \param rHost The location of the mailbox.
+ *
+ * \return If there is a pending communication on the mailbox, the method returns
+ * the PID of it sender. Otherwise the method returns -1.
+ *
+ * \exception If this method fails, it throws the exception described below:
+ *
+ * [BadAllocException] if there is not enough memory to build the default
+ * alias.
+ */
+ static int listenFromHost(const Host& rHost)
+ throw(BadAllocException);
+
+ /*! \brief Task::listenFromHost() - Tests whether there is a pending communication on the mailbox
+ * identified by the default alias and located on the host of the current process, and who sent it.
+ *
+ * \param rHost The location of the mailbox.
+ *
+ * \return If there is a pending communication on the mailbox, the method returns
+ * the PID of it sender. Otherwise the method returns -1.
+ *
+ * \exception If this method fails, it throws the exception described below:
+ *
+ * [BadAllocException] if there is not enough memory to build the default
+ * alias.
+ */
+ static int listenFromHost(const char* alias, const Host& rHost)
+ throw(NullPointerException);
+
+ virtual const Task& operator= (const Task& rTask);
+
+ protected:
+
+ // Attributes.
+
+ m_task_t nativeTask; // the native MSG task.
+ };
+
+ } // namespace Msg
+} // namespace SimGrid
+
+typedef Task* TaskPtr;
+
+#endif // §MSG_TASK_HPP
+