5 #include "simix/private.h"
6 #include "msg/datatypes.h"
9 #define MAX_ALIAS_NAME ((size_t)260)
11 * Initialization of the mailbox module.
13 void MSG_mailbox_mod_init(void);
16 * Terminaison of the mailbox module.
18 void MSG_mailbox_mod_exit(void);
21 /*! \brief MSG_mailbox_new - create a new mailbox.
23 * The function MSG_mailbox_new creates a new mailbox identified by the key specified
24 * by the parameter alias and add it in the global dictionary.
26 * \param alias The alias of the mailbox to create.
28 * \return The newly created mailbox.
30 msg_mailbox_t MSG_mailbox_new(const char *alias);
32 /*! \brief MSG_mailbox_create - create a new mailbox.
34 * The function MSG_mailbox_new creates a new mailbox identified by
35 * the key specified by the parameter alias and add it in the global
36 * dictionary but doesn't add it in the global dictionary. Typicaly,
37 * this type of mailbox is associated with a channel.
39 * \param alias The alias of the mailbox to create.
41 * \return The newly created mailbox.
43 msg_mailbox_t MSG_mailbox_create(const char *alias);
45 /* \brief MSG_mailbox_free - release a mailbox from the memory.
47 * The function MSG_mailbox_free release a mailbox from the memory but does
48 * not remove it from the dictionary.
50 * \param mailbox The mailbox to release.
52 * \see MSG_mailbox_destroy.
54 void MSG_mailbox_free(void *mailbox);
56 /* \brief MSG_mailbox_get_by_alias - get a mailbox from its alias.
58 * The function MSG_mailbox_get_by_alias returns the mailbox associated with
59 * the key specified by the parameter alias. If the mailbox does not exists,
60 * the function create it.
62 * \param alias The alias of the mailbox to return.
64 * \return The mailbox associated with the alias specified as parameter
65 * or a new mailbox if the key does not match.
67 msg_mailbox_t MSG_mailbox_get_by_alias(const char *alias);
69 /* \brief MSG_mailbox_get_by_channel - get a mailbox of the specified host from its channel.
71 * The function MSG_mailbox_get_by_channel returns the mailbox of the
72 * specified host from the channel specified by the parameter
73 * channel. If the mailbox does not exists, the function fails.
75 * \param host The host containing he mailbox to get.
76 * \param channel The channel used to identify the mailbox.
78 * \return The mailbox of the specified host associated the channel
79 * specified as parameter.
83 MSG_mailbox_get_by_channel(m_host_t host, m_channel_t channel);
85 /*! \brief MSG_mailbox_get_alias - get the alias associated with the mailbox.
87 * The function MSG_mailbox_get_alias returns the alias of the mailbox specified
88 * by the parameter mailbox.
90 * \param mailbox The mailbox to get the alias.
92 * \return The alias of the mailbox specified by the parameter mailbox.
94 const char *MSG_mailbox_get_alias(msg_mailbox_t mailbox);
96 /*! \brief MSG_mailbox_get_cond - get the simix condition of a mailbox.
98 * The function MSG_mailbox_get_cond returns the condition of the
99 * mailbox specified by the parameter mailbox.
101 * \param mailbox The mailbox to get the condition.
103 * \return The simix condition of the mailbox specified by the parameter mailbox.
105 smx_cond_t MSG_mailbox_get_cond(msg_mailbox_t mailbox);
107 /*! \brief MSG_mailbox_set_cond - set the simix condition of a mailbox.
109 * The function MSG_mailbox_set_cond set the condition of the mailbox
110 * specified by the parameter mailbox.
112 * \param mailbox The mailbox to set the condition.
113 * \param cond The new simix condition of the mailbox.
116 void MSG_mailbox_set_cond(msg_mailbox_t mailbox, smx_cond_t cond);
118 /*! \brief MSG_mailbox_get_hostname - get the name of the host owned a mailbox.
120 * The function MSG_mailbox_get_hostname returns name of the host
121 * owned the mailbox specified by the parameter mailbox.
123 * \param mailbox The mailbox to get the name of the host.
125 * \return The name of the host owned the mailbox specified by the parameter mailbox.
127 const char *MSG_mailbox_get_hostname(msg_mailbox_t mailbox);
129 /*! \brief MSG_mailbox_set_hostname - set the name of the host owned a mailbox.
131 * The function MSG_mailbox_set_hostname sets the name of the host
132 * owned the mailbox specified by the parameter mailbox.
134 * \param mailbox The mailbox to set the name of the host.
135 * \param hostname The name of the owner of the mailbox.
138 void MSG_mailbox_set_hostname(msg_mailbox_t mailbox, const char *hostname);
141 /*! \brief MSG_mailbox_is_empty - test if a mailbox is empty.
143 * The function MSG_mailbox_is_empty tests if a mailbox is empty
144 * (contains no msg task).
146 * \param mailbox The mailbox to get test.
148 * \return The function returns 1 if the mailbox is empty. Otherwise the function
151 int MSG_mailbox_is_empty(msg_mailbox_t mailbox);
153 /*! \brief MSG_mailbox_put - put a task in a mailbox.
155 * The MSG_mailbox_put puts a task in a specified mailbox.
157 * \param mailbox The mailbox where put the task.
158 * \param task The task to put in the mailbox.
160 void MSG_mailbox_put(msg_mailbox_t mailbox, m_task_t task);
162 /*! \brief MSG_mailbox_remove - remove a task from a mailbox.
164 * The MSG_mailbox_remove removes a task from a specified mailbox.
166 * \param mailbox The mailbox concerned by this operation.
167 * \param task The task to remove from the mailbox.
169 void MSG_mailbox_remove(msg_mailbox_t mailbox, m_task_t task);
171 /*! \brief MSG_mailbox_get_head - get the task at the head of a mailbox.
173 * The MSG_mailbox_get_head returns the task at the head of the mailbox.
174 * This function does not remove the task from the mailbox (contrary to
175 * the function MSG_mailbox_pop_head).
177 * \param mailbox The mailbox concerned by the operation.
179 * \return The task at the head of the mailbox.
181 m_task_t MSG_mailbox_get_head(msg_mailbox_t mailbox);
183 /*! \brief MSG_mailbox_pop_head - get the task at the head of a mailbox
184 * and remove it from it.
186 * The MSG_mailbox_pop_head returns the task at the head of the mailbox
187 * and remove it from it.
189 * \param mailbox The mailbox concerned by the operation.
191 * \return The task at the head of the mailbox.
193 m_task_t MSG_mailbox_pop_head(msg_mailbox_t mailbox);
195 /*! \brief MSG_mailbox_get_first_host_task - get the first msg task
196 * of a specified mailbox, sended by a process of a specified host.
198 * \param mailbox The mailbox concerned by the operation.
199 * \param host The msg host of the process that has sended the
202 * \return The first task in the mailbox specified by the
203 * parameter mailbox and sended by a process located
204 * on the host specified by the parameter host.
207 MSG_mailbox_get_first_host_task(msg_mailbox_t mailbox, m_host_t host);
209 /*! \brief MSG_mailbox_get_count_host_waiting_tasks - Return the number of tasks
210 waiting to be received in a mailbox and sent by a host.
212 * \param mailbox The mailbox concerned by the operation.
213 * \param host The msg host containing the processes that have sended the
216 * \return The number of tasks in the mailbox specified by the
217 * parameter mailbox and sended by all the processes located
218 * on the host specified by the parameter host.
221 MSG_mailbox_get_count_host_waiting_tasks(msg_mailbox_t mailbox,
227 #endif /* !SMX_MAILBOX_H */