Logo AND Algorithmique Numérique Distribuée

Public GIT Repository
89fbf09fc48d785530e097b0171b4715d17478bf
[simgrid.git] / src / msg / mailbox.h
1 #ifndef SMX_MAILBOX_H
2 #define SMX_MAILBOX_H
3
4 #include "xbt/fifo.h"
5 #include "simix/private.h"
6 #include "msg/datatypes.h"
7
8 SG_BEGIN_DECL()
9 #define MAX_ALIAS_NAME  ((size_t)260)
10 /*
11  * Initialization of the mailbox module.
12  */
13 void MSG_mailbox_mod_init(void);
14
15 /*
16  * Terminaison of the mailbox module.
17  */
18 void MSG_mailbox_mod_exit(void);
19
20
21 /*! \brief MSG_mailbox_new - create a new mailbox.
22  *
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.
25  *
26  * \param alias         The alias of the mailbox to create.
27  * 
28  * \return              The newly created mailbox.
29  */
30 XBT_PUBLIC(msg_mailbox_t)
31 MSG_mailbox_new(const char *alias);
32
33 /*! \brief MSG_mailbox_create - create a new mailbox.
34  *
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.
39  *
40  * \param alias         The alias of the mailbox to create.
41  * 
42  * \return              The newly created mailbox.
43  */
44 msg_mailbox_t
45 MSG_mailbox_create(const char *alias);
46
47 /* \brief MSG_mailbox_free - release a mailbox from the memory.
48  *
49  * The function MSG_mailbox_free release a mailbox from the memory but does
50  * not remove it from the dictionary.
51  *
52  * \param mailbox       The mailbox to release.
53  *
54  * \see                 MSG_mailbox_destroy.
55  */
56 void
57 MSG_mailbox_free(void *mailbox);
58
59 /* \brief MSG_mailbox_get_by_alias - get a mailbox from its alias.
60  *
61  * The function MSG_mailbox_get_by_alias returns the mailbox associated with
62  * the key specified by the parameter alias. If the mailbox does not exists,
63  * the function create it.
64  *
65  * \param alias         The alias of the mailbox to return.
66  *
67  * \return      The mailbox associated with the alias specified as parameter
68  *              or a new mailbox if the key does not match.
69  */
70 XBT_PUBLIC(msg_mailbox_t)
71 MSG_mailbox_get_by_alias(const char *alias);
72
73 /* \brief MSG_mailbox_get_by_channel - get a mailbox of the specified host from its channel.
74  *
75  * The function MSG_mailbox_get_by_channel returns the mailbox of the
76  * specified host from the channel specified by the parameter
77  * channel. If the mailbox does not exists, the function fails.
78  *
79  * \param host          The host containing he mailbox to get.
80  * \param channel       The channel used to identify the mailbox.
81  *
82  * \return The mailbox of the specified host associated the channel
83  *         specified as parameter.
84  *              
85  */
86 XBT_PUBLIC(msg_mailbox_t)
87 MSG_mailbox_get_by_channel(m_host_t host, m_channel_t channel);
88
89 /*! \brief MSG_mailbox_get_alias - get the alias associated with the mailbox.
90  *
91  * The function MSG_mailbox_get_alias returns the alias of the mailbox specified
92  * by the parameter mailbox.
93  *
94  * \param mailbox       The mailbox to get the alias.
95  *
96  * \return      The alias of the mailbox specified by the parameter mailbox.
97  */
98 XBT_PUBLIC(const char *)
99 MSG_mailbox_get_alias(msg_mailbox_t mailbox);
100
101 /*! \brief MSG_mailbox_get_cond - get the simix condition of a mailbox.
102  *
103  * The function MSG_mailbox_get_cond returns the condition of the
104  * mailbox specified by the parameter mailbox.
105  *
106  * \param mailbox       The mailbox to get the condition.
107  *
108  * \return The simix condition of the mailbox specified by the parameter mailbox.
109  */
110 XBT_PUBLIC(smx_cond_t)
111 MSG_mailbox_get_cond(msg_mailbox_t mailbox);
112
113 /*! \brief MSG_mailbox_set_cond - set the simix condition of a mailbox.
114  *
115  * The function MSG_mailbox_set_cond set the condition of the mailbox
116  * specified by the parameter mailbox.
117  *
118  * \param mailbox       The mailbox to set the condition.
119  * \param cond          The new simix condition of the mailbox.
120  *
121  */
122 XBT_PUBLIC(void)
123 MSG_mailbox_set_cond(msg_mailbox_t mailbox, smx_cond_t cond);
124
125 /*! \brief MSG_mailbox_get_hostname - get the name of the host owned a mailbox.
126  *
127  * The function MSG_mailbox_get_hostname returns name of the host
128  * owned the mailbox specified by the parameter mailbox.
129  *
130  * \param mailbox       The mailbox to get the name of the host.
131  *
132  * \return The name of the host owned the mailbox specified by the parameter mailbox.
133  */
134 XBT_PUBLIC(const char *)
135 MSG_mailbox_get_hostname(msg_mailbox_t mailbox);
136
137 /*! \brief MSG_mailbox_set_hostname - set the name of the host owned a mailbox.
138  *
139  * The function MSG_mailbox_set_hostname sets the name of the host
140  * owned the mailbox specified by the parameter mailbox.
141  *
142  * \param mailbox       The mailbox to set the name of the host.
143  * \param hostname      The name of the owner of the mailbox.
144  *
145  */
146 XBT_PUBLIC(void)
147 MSG_mailbox_set_hostname(msg_mailbox_t mailbox, const char *hostname);
148
149
150 /*! \brief MSG_mailbox_is_empty - test if a mailbox is empty.
151  *
152  * The function MSG_mailbox_is_empty tests if a mailbox is empty
153  * (contains no msg task).
154  *
155  * \param mailbox       The mailbox to get test.
156  *
157  * \return      The function returns 1 if the mailbox is empty. Otherwise the function
158  *              returns 0.
159  */
160 XBT_PUBLIC(int)
161 MSG_mailbox_is_empty(msg_mailbox_t mailbox);
162
163 /*! \brief MSG_mailbox_put - put a task in a mailbox.
164  *
165  * The MSG_mailbox_put puts a task in a specified mailbox.
166  *
167  * \param mailbox       The mailbox where put the task.
168  * \param task          The task to put in the mailbox.
169  */
170 XBT_PUBLIC(void)
171 MSG_mailbox_put(msg_mailbox_t mailbox, m_task_t task);
172
173 /*! \brief MSG_mailbox_remove - remove a task from a mailbox.
174  *
175  * The MSG_mailbox_remove removes a task from a specified mailbox.
176  *
177  * \param mailbox       The mailbox concerned by this operation.
178  * \param task          The task to remove from the mailbox.
179  */
180 XBT_PUBLIC(void)
181 MSG_mailbox_remove(msg_mailbox_t mailbox, m_task_t task);
182
183 /*! \brief MSG_mailbox_get_head - get the task at the head of a mailbox.
184  *
185  * The MSG_mailbox_get_head returns the task at the head of the mailbox.
186  * This function does not remove the task from the mailbox (contrary to
187  * the function MSG_mailbox_pop_head).
188  *
189  * \param mailbox       The mailbox concerned by the operation.
190  *
191  * \return              The task at the head of the mailbox.
192  */
193 XBT_PUBLIC(m_task_t)
194 MSG_mailbox_get_head(msg_mailbox_t mailbox);
195
196 /*! \brief MSG_mailbox_pop_head - get the task at the head of a mailbox
197  * and remove it from it.
198  *
199  * The MSG_mailbox_pop_head returns the task at the head of the mailbox
200  * and remove it from it.
201  *
202  * \param mailbox       The mailbox concerned by the operation.
203  *
204  * \return              The task at the head of the mailbox.
205  */
206 XBT_PUBLIC(m_task_t)
207 MSG_mailbox_pop_head(msg_mailbox_t mailbox);
208
209 /*! \brief MSG_mailbox_get_first_host_task - get the first msg task
210  * of a specified mailbox, sended by a process of a specified host.
211  *
212  * \param mailbox       The mailbox concerned by the operation.
213  * \param host          The msg host of the process that has sended the
214  *                      task.
215  *
216  * \return              The first task in the mailbox specified by the
217  *                      parameter mailbox and sended by a process located
218  *                      on the host specified by the parameter host.
219  */
220 XBT_PUBLIC(m_task_t)
221 MSG_mailbox_get_first_host_task(msg_mailbox_t mailbox, m_host_t host);
222
223 /*! \brief MSG_mailbox_get_count_host_waiting_tasks - Return the number of tasks 
224    waiting to be received in a mailbox and sent by a host.
225  *
226  * \param mailbox       The mailbox concerned by the operation.
227  * \param host          The msg host containing the processes that have sended the
228  *                      tasks.
229  *
230  * \return              The number of tasks in the mailbox specified by the
231  *                      parameter mailbox and sended by all the processes located
232  *                      on the host specified by the parameter host.
233  */
234 XBT_PUBLIC(int)
235 MSG_mailbox_get_count_host_waiting_tasks(msg_mailbox_t mailbox,
236                                          m_host_t host);
237
238
239 SG_END_DECL()
240
241 #endif                          /* !SMX_MAILBOX_H */