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 XBT_PUBLIC(msg_mailbox_t)
31 MSG_mailbox_new(const char *alias);
33 /*! \brief MSG_mailbox_create - create a new mailbox.
35 * The function MSG_mailbox_new creates a new mailbox identified by
36 * the key specified by the parameter alias and add it in the global
37 * dictionary but doesn't add it in the global dictionary. Typicaly,
38 * this type of mailbox is associated with a channel.
40 * \param alias The alias of the mailbox to create.
42 * \return The newly created mailbox.
44 msg_mailbox_t MSG_mailbox_create(const char *alias);
46 /* \brief MSG_mailbox_free - release a mailbox from the memory.
48 * The function MSG_mailbox_free release a mailbox from the memory but does
49 * not remove it from the dictionary.
51 * \param mailbox The mailbox to release.
53 * \see MSG_mailbox_destroy.
55 void MSG_mailbox_free(void *mailbox);
57 /* \brief MSG_mailbox_get_by_alias - get a mailbox from its alias.
59 * The function MSG_mailbox_get_by_alias returns the mailbox associated with
60 * the key specified by the parameter alias. If the mailbox does not exists,
61 * the function create it.
63 * \param alias The alias of the mailbox to return.
65 * \return The mailbox associated with the alias specified as parameter
66 * or a new mailbox if the key does not match.
68 XBT_PUBLIC(msg_mailbox_t)
69 MSG_mailbox_get_by_alias(const char *alias);
71 /* \brief MSG_mailbox_get_by_channel - get a mailbox of the specified host from its channel.
73 * The function MSG_mailbox_get_by_channel returns the mailbox of the
74 * specified host from the channel specified by the parameter
75 * channel. If the mailbox does not exists, the function fails.
77 * \param host The host containing he mailbox to get.
78 * \param channel The channel used to identify the mailbox.
80 * \return The mailbox of the specified host associated the channel
81 * specified as parameter.
84 XBT_PUBLIC(msg_mailbox_t)
85 MSG_mailbox_get_by_channel(m_host_t host, m_channel_t channel);
87 /*! \brief MSG_mailbox_get_alias - get the alias associated with the mailbox.
89 * The function MSG_mailbox_get_alias returns the alias of the mailbox specified
90 * by the parameter mailbox.
92 * \param mailbox The mailbox to get the alias.
94 * \return The alias of the mailbox specified by the parameter mailbox.
96 XBT_PUBLIC(const char *) MSG_mailbox_get_alias(msg_mailbox_t mailbox);
98 /*! \brief MSG_mailbox_get_cond - get the simix condition of a mailbox.
100 * The function MSG_mailbox_get_cond returns the condition of the
101 * mailbox specified by the parameter mailbox.
103 * \param mailbox The mailbox to get the condition.
105 * \return The simix condition of the mailbox specified by the parameter mailbox.
107 XBT_PUBLIC(smx_cond_t)
108 MSG_mailbox_get_cond(msg_mailbox_t mailbox);
110 /*! \brief MSG_mailbox_set_cond - set the simix condition of a mailbox.
112 * The function MSG_mailbox_set_cond set the condition of the mailbox
113 * specified by the parameter mailbox.
115 * \param mailbox The mailbox to set the condition.
116 * \param cond The new simix condition of the mailbox.
119 XBT_PUBLIC(void) MSG_mailbox_set_cond(msg_mailbox_t mailbox, smx_cond_t cond);
121 /*! \brief MSG_mailbox_get_hostname - get the name of the host owned a mailbox.
123 * The function MSG_mailbox_get_hostname returns name of the host
124 * owned the mailbox specified by the parameter mailbox.
126 * \param mailbox The mailbox to get the name of the host.
128 * \return The name of the host owned the mailbox specified by the parameter mailbox.
130 XBT_PUBLIC(const char *) MSG_mailbox_get_hostname(msg_mailbox_t mailbox);
132 /*! \brief MSG_mailbox_set_hostname - set the name of the host owned a mailbox.
134 * The function MSG_mailbox_set_hostname sets the name of the host
135 * owned the mailbox specified by the parameter mailbox.
137 * \param mailbox The mailbox to set the name of the host.
138 * \param hostname The name of the owner of the mailbox.
142 MSG_mailbox_set_hostname(msg_mailbox_t mailbox, const char *hostname);
145 /*! \brief MSG_mailbox_is_empty - test if a mailbox is empty.
147 * The function MSG_mailbox_is_empty tests if a mailbox is empty
148 * (contains no msg task).
150 * \param mailbox The mailbox to get test.
152 * \return The function returns 1 if the mailbox is empty. Otherwise the function
155 XBT_PUBLIC(int) MSG_mailbox_is_empty(msg_mailbox_t mailbox);
157 /*! \brief MSG_mailbox_remove - remove a task from a mailbox.
159 * The MSG_mailbox_remove removes a task from a specified mailbox.
161 * \param mailbox The mailbox concerned by this operation.
162 * \param task The task to remove from the mailbox.
164 XBT_PUBLIC(void) MSG_mailbox_remove(msg_mailbox_t mailbox, m_task_t task);
166 /*! \brief MSG_mailbox_get_head - get the task at the head of a mailbox.
168 * The MSG_mailbox_get_head returns the task at the head of the mailbox.
169 * This function does not remove the task from the mailbox (contrary to
170 * the function MSG_mailbox_pop_head).
172 * \param mailbox The mailbox concerned by the operation.
174 * \return The task at the head of the mailbox.
177 MSG_mailbox_get_head(msg_mailbox_t mailbox);
179 /*! \brief MSG_mailbox_pop_head - get the task at the head of a mailbox
180 * and remove it from it.
182 * The MSG_mailbox_pop_head returns the task at the head of the mailbox
183 * and remove it from it.
185 * \param mailbox The mailbox concerned by the operation.
187 * \return The task at the head of the mailbox.
190 MSG_mailbox_pop_head(msg_mailbox_t mailbox);
192 /*! \brief MSG_mailbox_get_first_host_task - get the first msg task
193 * of a specified mailbox, sended by a process of a specified host.
195 * \param mailbox The mailbox concerned by the operation.
196 * \param host The msg host of the process that has sended the
199 * \return The first task in the mailbox specified by the
200 * parameter mailbox and sended by a process located
201 * on the host specified by the parameter host.
204 MSG_mailbox_get_first_host_task(msg_mailbox_t mailbox, m_host_t host);
206 /*! \brief MSG_mailbox_get_count_host_waiting_tasks - Return the number of tasks
207 waiting to be received in a mailbox and sent by a host.
209 * \param mailbox The mailbox concerned by the operation.
210 * \param host The msg host containing the processes that have sended the
213 * \return The number of tasks in the mailbox specified by the
214 * parameter mailbox and sended by all the processes located
215 * on the host specified by the parameter host.
218 MSG_mailbox_get_count_host_waiting_tasks(msg_mailbox_t mailbox,
223 #endif /* !SMX_MAILBOX_H */