Logo AND Algorithmique Numérique Distribuée

Public GIT Repository
Do not require doxygen in maintainer mode
[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_remove - remove a task from a mailbox.
164  *
165  * The MSG_mailbox_remove removes a task from a specified mailbox.
166  *
167  * \param mailbox       The mailbox concerned by this operation.
168  * \param task          The task to remove from the mailbox.
169  */
170 XBT_PUBLIC(void)
171 MSG_mailbox_remove(msg_mailbox_t mailbox, m_task_t task);
172
173 /*! \brief MSG_mailbox_get_head - get the task at the head of a mailbox.
174  *
175  * The MSG_mailbox_get_head returns the task at the head of the mailbox.
176  * This function does not remove the task from the mailbox (contrary to
177  * the function MSG_mailbox_pop_head).
178  *
179  * \param mailbox       The mailbox concerned by the operation.
180  *
181  * \return              The task at the head of the mailbox.
182  */
183 XBT_PUBLIC(m_task_t)
184 MSG_mailbox_get_head(msg_mailbox_t mailbox);
185
186 /*! \brief MSG_mailbox_pop_head - get the task at the head of a mailbox
187  * and remove it from it.
188  *
189  * The MSG_mailbox_pop_head returns the task at the head of the mailbox
190  * and remove it from it.
191  *
192  * \param mailbox       The mailbox concerned by the operation.
193  *
194  * \return              The task at the head of the mailbox.
195  */
196 XBT_PUBLIC(m_task_t)
197 MSG_mailbox_pop_head(msg_mailbox_t mailbox);
198
199 /*! \brief MSG_mailbox_get_first_host_task - get the first msg task
200  * of a specified mailbox, sended by a process of a specified host.
201  *
202  * \param mailbox       The mailbox concerned by the operation.
203  * \param host          The msg host of the process that has sended the
204  *                      task.
205  *
206  * \return              The first task in the mailbox specified by the
207  *                      parameter mailbox and sended by a process located
208  *                      on the host specified by the parameter host.
209  */
210 XBT_PUBLIC(m_task_t)
211 MSG_mailbox_get_first_host_task(msg_mailbox_t mailbox, m_host_t host);
212
213 /*! \brief MSG_mailbox_get_count_host_waiting_tasks - Return the number of tasks
214    waiting to be received in a mailbox and sent by a host.
215  *
216  * \param mailbox       The mailbox concerned by the operation.
217  * \param host          The msg host containing the processes that have sended the
218  *                      tasks.
219  *
220  * \return              The number of tasks in the mailbox specified by the
221  *                      parameter mailbox and sended by all the processes located
222  *                      on the host specified by the parameter host.
223  */
224 XBT_PUBLIC(int)
225 MSG_mailbox_get_count_host_waiting_tasks(msg_mailbox_t mailbox,
226                                          m_host_t host);
227
228
229 SG_END_DECL()
230
231 #endif                          /* !SMX_MAILBOX_H */