Logo AND Algorithmique Numérique Distribuée

Public GIT Repository
fix: correct trace mask checking
[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/simix.h"
6 #include "msg/datatypes.h"
7
8
9 SG_BEGIN_DECL()
10 #define MAX_ALIAS_NAME  ((size_t)260)
11 /*
12  * Initialization of the mailbox module.
13  */
14      void MSG_mailbox_mod_init(void);
15
16 /*
17  * Terminaison of the mailbox module.
18  */
19      void MSG_mailbox_mod_exit(void);
20
21
22 /*! \brief MSG_mailbox_new - create a new mailbox.
23  *
24  * The function MSG_mailbox_new creates a new mailbox identified by the key specified
25  * by the parameter alias and add it in the global dictionary.
26  *
27  * \param alias         The alias of the mailbox to create.
28  *
29  * \return              The newly created mailbox.
30  */
31 XBT_PUBLIC(msg_mailbox_t)
32   MSG_mailbox_new(const char *alias);
33
34 /*! \brief MSG_mailbox_create - create a new mailbox.
35  *
36  * The function MSG_mailbox_new creates a new mailbox identified by
37  * the key specified by the parameter alias and add it in the global
38  * dictionary but doesn't add it in the global dictionary. Typicaly,
39  * this type of mailbox is associated with a channel.
40  *
41  * \param alias         The alias of the mailbox to create.
42  *
43  * \return              The newly created mailbox.
44  */
45      msg_mailbox_t 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 MSG_mailbox_free(void *mailbox);
57
58 /* \brief MSG_mailbox_get_by_alias - get a mailbox from its alias.
59  *
60  * The function MSG_mailbox_get_by_alias returns the mailbox associated with
61  * the key specified by the parameter alias. If the mailbox does not exists,
62  * the function create it.
63  *
64  * \param alias         The alias of the mailbox to return.
65  *
66  * \return      The mailbox associated with the alias specified as parameter
67  *              or a new mailbox if the key does not match.
68  */
69 XBT_PUBLIC(msg_mailbox_t)
70   MSG_mailbox_get_by_alias(const char *alias);
71
72 /* \brief MSG_mailbox_get_by_channel - get a mailbox of the specified host from its channel.
73  *
74  * The function MSG_mailbox_get_by_channel returns the mailbox of the
75  * specified host from the channel specified by the parameter
76  * channel. If the mailbox does not exists, the function fails.
77  *
78  * \param host          The host containing he mailbox to get.
79  * \param channel       The channel used to identify the mailbox.
80  *
81  * \return The mailbox of the specified host associated the channel
82  *         specified as parameter.
83  *
84  */
85 XBT_PUBLIC(msg_mailbox_t)
86   MSG_mailbox_get_by_channel(m_host_t host, m_channel_t channel);
87
88 /*! \brief MSG_mailbox_get_alias - get the alias associated with the mailbox.
89  *
90  * The function MSG_mailbox_get_alias returns the alias of the mailbox specified
91  * by the parameter mailbox.
92  *
93  * \param mailbox       The mailbox to get the alias.
94  *
95  * \return      The alias of the mailbox specified by the parameter mailbox.
96  */
97 XBT_PUBLIC(const char *) MSG_mailbox_get_alias(msg_mailbox_t mailbox);
98
99 /*! \brief MSG_mailbox_get_cond - get the simix condition of a mailbox.
100  *
101  * The function MSG_mailbox_get_cond returns the condition of the
102  * mailbox specified by the parameter mailbox.
103  *
104  * \param mailbox       The mailbox to get the condition.
105  *
106  * \return The simix condition of the mailbox specified by the parameter mailbox.
107  */
108 XBT_PUBLIC(smx_cond_t)
109   MSG_mailbox_get_cond(msg_mailbox_t mailbox);
110
111 /*! \brief MSG_mailbox_set_cond - set the simix condition of a mailbox.
112  *
113  * The function MSG_mailbox_set_cond set the condition of the mailbox
114  * specified by the parameter mailbox.
115  *
116  * \param mailbox       The mailbox to set the condition.
117  * \param cond          The new simix condition of the mailbox.
118  *
119  */
120 XBT_PUBLIC(void) MSG_mailbox_set_cond(msg_mailbox_t mailbox, smx_cond_t cond);
121
122 /*! \brief MSG_mailbox_is_empty - test if a mailbox is empty.
123  *
124  * The function MSG_mailbox_is_empty tests if a mailbox is empty
125  * (contains no msg task).
126  *
127  * \param mailbox       The mailbox to get test.
128  *
129  * \return      The function returns 1 if the mailbox is empty. Otherwise the function
130  *              returns 0.
131  */
132 XBT_PUBLIC(int) MSG_mailbox_is_empty(msg_mailbox_t mailbox);
133
134 /*! \brief MSG_mailbox_get_head - get the task at the head of a mailbox.
135  *
136  * The MSG_mailbox_get_head returns the task at the head of the mailbox.
137  * This function does not remove the task from the mailbox (contrary to
138  * the function MSG_mailbox_pop_head).
139  *
140  * \param mailbox       The mailbox concerned by the operation.
141  *
142  * \return              The task at the head of the mailbox.
143  */
144 XBT_PUBLIC(m_task_t)
145   MSG_mailbox_get_head(msg_mailbox_t mailbox);
146
147 /*! \brief MSG_mailbox_get_count_host_waiting_tasks - Return the number of tasks
148    waiting to be received in a mailbox and sent by a host.
149  *
150  * \param mailbox       The mailbox concerned by the operation.
151  * \param host          The msg host containing the processes that have sended the
152  *                      tasks.
153  *
154  * \return              The number of tasks in the mailbox specified by the
155  *                      parameter mailbox and sended by all the processes located
156  *                      on the host specified by the parameter host.
157  */
158 XBT_PUBLIC(int)
159 MSG_mailbox_get_count_host_waiting_tasks(msg_mailbox_t mailbox,
160                                          m_host_t host);
161
162
163 SG_END_DECL()
164 #endif /* !SMX_MAILBOX_H */