\r
// Compilation C++ recquise\r
#ifndef __cplusplus\r
- #error Process.hpp requires C++ compilation (use a .cxx suffix)\r
+ #error Task.hpp requires C++ compilation (use a .cxx suffix)\r
#endif\r
\r
+#include <msg/datatypes.h>\r
+\r
+#include <Config.hpp>\r
+\r
+#include <Object.hpp>\r
+\r
namespace SimGrid\r
{\r
namespace Msg\r
{\r
+ class MsgException;\r
+ class InvalidArgumentException;\r
+ class NullPointerException;\r
+ class MsgException;\r
+ class BadAllocException;\r
+\r
+ class Process;\r
+ class Host;\r
+\r
// SimGrid::Msg::Task wrapper class declaration.\r
- class Task\r
+ class SIMGRIDX_EXPORT Task : public Object\r
{\r
+ MSG_DECLARE_DYNAMIC(Task);\r
+\r
+ friend Process;\r
+ friend Host;\r
+\r
protected:\r
// Default constructor.\r
Task();\r
+\r
+ class Ref\r
+ {\r
+ public:\r
+ Ref(Task* task)\r
+ {\r
+ count = 1;\r
+ this->task = task;\r
+ }\r
+\r
+ virtual ~Ref(){}\r
+\r
+ void operator++(void){\r
+ count++;\r
+ \r
+ }\r
+\r
+ void operator--(void){\r
+ if(--count <= 0)\r
+ delete p;\r
+ }\r
+\r
+ private:\r
+ int count;\r
+ Task* task;\r
+\r
+ };\r
\r
public:\r
/*! \brief Copy constructor.\r
* \r
* [MsgException] if an internal excpetion occurs.\r
*/\r
- static Task& get(int channel) \r
- throw(InvalidArgumentException, MsgException); \r
- \r
+ /*static Task& get(int channel) \r
+ throw(InvalidArgumentException, MsgException);*/\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
*\r
* \param channel The channel number.\r
*\r
- * \return If there is a waiting task on the channel the method returns true. Otherwise\r
- * the method returns false.\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 bool probe(int channel)\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
* [MsgException] if an internal exception occurs.\r
*/\r
void send(double timeout) \r
- throw(BadAllocationException, InvalidArgumentException, MsgException);\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
* [MsgException] if an internal exception occurs.\r
*/\r
- static Task& receive(void) \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
*\r
* [MsgException] if an internal exception occurs.\r
*/\r
- static Task& receive(const char* alias) \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
*\r
* [BadAllocException] if there is not enough memory to build the default alias.\r
*/\r
- static bool listen(void) \r
+ static int listen(void) \r
throw(BadAllocException);\r
\r
/*! \brief Task::listen() - Listen whether there is a waiting task on the mailbox \r
*\r
* \param alias The alias of the mailbox.\r
*\r
- * \return If there is a waiting task on the mailbox the method returns true.\r
- * Otherwise the method returns false.\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 bool listen(const char* alias) \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
* [BadAllocException] if there is not enough memory to build the default\r
* alias.\r
*/\r
- static bool listenFromHost(const char* alias, const Host& rHost) \r
- throw(NullPointerException, NativeException);\r
+ static int listenFromHost(const char* alias, const Host& rHost) \r
+ throw(NullPointerException, MsgException);\r
+\r
+ virtual const Task& operator= (const Task& rTask);\r
\r
- private:\r
+ protected:\r
\r
// Attributes.\r
\r
- m_task_t nativeTask; // the native MSG task.\r
+ m_task_t nativeTask; // the native MSG task.\r
+\r
+ Ref* ref;\r
};\r
\r
} // namespace Msg \r
} // namespace SimGrid\r
\r
+typedef Task* TaskPtr;\r
+\r
#endif // §MSG_TASK_HPP
\ No newline at end of file