Logo AND Algorithmique Numérique Distribuée

Public GIT Repository
This change is relative with the mailbox concept :
[simgrid.git] / src / msg / msg_mailbox.h
index 94e0c2a..9534f04 100644 (file)
@@ -5,20 +5,12 @@
 #include "simix/private.h"\r
 #include "msg/datatypes.h"\r
 \r
-#ifdef __cplusplus\r
-extern "C" {\r
-#endif\r
+SG_BEGIN_DECL()\r
 \r
 #define MAX_ALIAS_NAME ((size_t)260)\r
 \r
-/* this structure represents a mailbox */\r
-typedef struct s_msg_mailbox\r
-{\r
-       char* alias;                    /* the key of the mailbox in the dictionary                             */\r
-       xbt_fifo_t tasks;               /* the list of the tasks in the mailbox                                 */\r
-       smx_cond_t cond;                /* the condition on the mailbox                                                 */\r
-       char* hostname;                 /* the name of the host containing the mailbox                  */\r
-}s_msg_mailbox_t, * msg_mailbox_t;\r
+/* forward declaration */\r
+typedef struct s_msg_mailbox* msg_mailbox_t;\r
 \r
 /*\r
  * Initialization of the mailbox module.\r
@@ -32,21 +24,11 @@ MSG_mailbox_mod_init(void);
 void\r
 MSG_mailbox_mod_exit(void);\r
 \r
-/*! \brief MSG_get_mailboxes - get the dictionary containing all the mailboxes.\r
- * \r
- * The function MSG_get_mailboxes returns the dictionary containing all the mailboxes\r
- * of the simulation. A mailbox allow different processes to communicate using msg tasks.\r
- * It is identified by an alias which is a key of the dictionary containing all of them.\r
- * \r
- * \return     The dictionary containing all the mailboxes of the simulation.\r
- */\r
-xbt_dict_t\r
-MSG_get_mailboxes(void);\r
 \r
 /*! \brief MSG_mailbox_new - create a new mailbox.\r
  *\r
  * The function MSG_mailbox_new creates a new mailbox identified by the key specified\r
- * by the parameter alias.\r
+ * by the parameter alias and add it in the global dictionary.\r
  *\r
  * \param alias                The alias of the mailbox to create.\r
  * \r
@@ -55,19 +37,18 @@ MSG_get_mailboxes(void);
 msg_mailbox_t\r
 MSG_mailbox_new(const char *alias);\r
 \r
-/* \brief MSG_mailbox_destroy - destroy a mailbox.\r
+/*! \brief MSG_mailbox_create - create a new mailbox.\r
  *\r
- * The function MSG_mailbox_destroy removes a mailbox from the dictionary containing\r
- * all the mailbox of the simulation an release it from the memory. This function is\r
- * different to the MSG_mailbox_free which only release a mailbox from the memory but\r
- does not remove it from the dictionary.\r
- *\r
- * \param mailbox      The mailbox to destroy.\r
+ * The function MSG_mailbox_new creates a new mailbox identified by the key specified\r
+ * by the parameter alias and add it in the global dictionary but doesn't add it in\r
+ * the global dictionary. Typicaly, this type of mailbox is associated with a channel.\r
  *\r
- * \see                                MSG_mailbox_free.\r
+ * \param alias                The alias of the mailbox to create.\r
+ * \r
+ * \return                     The newly created mailbox.\r
  */\r
-void\r
-MSG_mailbox_destroy(msg_mailbox_t* mailbox);\r
+msg_mailbox_t\r
+MSG_mailbox_create(const char *alias);\r
 \r
 /* \brief MSG_mailbox_free - release a mailbox from the memory.\r
  *\r
@@ -95,6 +76,21 @@ MSG_mailbox_free(void* mailbox);
 msg_mailbox_t\r
 MSG_mailbox_get_by_alias(const char* alias);\r
 \r
+/* \brief MSG_mailbox_get_by_channel - get a mailbox of the specified host from its channel.\r
+ *\r
+ * The function MSG_mailbox_get_by_channel returns the mailbox of the specified host\r
+ * from the channel specified by the parameter channel. If the mailbox does not exists,\r
+ * the function fails.\r
+ *\r
+ * \param host         The host containing he mailbox to get.\r
+ * \param channel      The channel used to identify the mailbox.\r
+ *\r
+ * \return                     The mailbox of the specified host associated the channel specified as parameter.\r
+ *             \r
+ */\r
+msg_mailbox_t\r
+MSG_mailbox_get_by_channel(m_host_t host, m_channel_t channel);\r
+\r
 /*! \brief MSG_mailbox_get_alias - get the alias associated with the mailbox.\r
  *\r
  * The function MSG_mailbox_get_alias returns the alias of the mailbox specified\r
@@ -228,8 +224,8 @@ MSG_mailbox_pop_head(msg_mailbox_t mailbox);
 m_task_t\r
 MSG_mailbox_get_first_host_task(msg_mailbox_t mailbox, m_host_t host);\r
 \r
-/*! \brief MSG_mailbox_get_count_host_tasks - get the number of msg tasks\r
* of a specified mailbox, sended by all the process of a specified host.\r
+/*! \brief MSG_mailbox_get_count_host_waiting_tasks - Return the number of tasks \r
  waiting to be received in a mailbox and sent by a host.\r
  *\r
  * \param mailbox      The mailbox concerned by the operation.\r
  * \param host         The msg host containing the processes that have sended the\r
@@ -240,12 +236,18 @@ MSG_mailbox_get_first_host_task(msg_mailbox_t mailbox, m_host_t host);
  *                                     on the host specified by the parameter host.\r
  */\r
 int\r
-MSG_mailbox_get_count_host_tasks(msg_mailbox_t mailbox, m_host_t host);\r
+MSG_mailbox_get_count_host_waiting_tasks(msg_mailbox_t mailbox, m_host_t host);\r
+\r
+\r
+MSG_error_t \r
+MSG_mailbox_get_task_ext(msg_mailbox_t mailbox, m_task_t* task, m_host_t host, double timeout);\r
+\r
+\r
+MSG_error_t \r
+MSG_mailbox_put_with_timeout(msg_mailbox_t mailbox, m_task_t task, double timeout);\r
 \r
+SG_END_DECL()\r
 \r
-#ifdef __cplusplus\r
-}\r
-#endif\r
 \r
 #endif /* !SMX_MAILBOX_H */\r
 \r