1 /* Copyright (c) 2008, 2009, 2010. The SimGrid Team.
2 * All rights reserved. */
4 /* This program is free software; you can redistribute it and/or modify it
5 * under the terms of the license (GNU LGPL) which comes with this package. */
11 #include "simix/simix.h"
12 #include "msg/datatypes.h"
16 #define MAX_ALIAS_NAME ((size_t)260)
18 * Initialization of the mailbox module.
20 void MSG_mailbox_mod_init(void);
23 * Terminaison of the mailbox module.
25 void MSG_mailbox_mod_exit(void);
28 /*! \brief MSG_mailbox_new - create a new mailbox.
30 * The function MSG_mailbox_new creates a new mailbox identified by the key specified
31 * by the parameter alias and add it in the global dictionary.
33 * \param alias The alias of the mailbox to create.
35 * \return The newly created mailbox.
37 XBT_PUBLIC(msg_mailbox_t)
38 MSG_mailbox_new(const char *alias);
40 /*! \brief MSG_mailbox_create - create a new mailbox.
42 * The function MSG_mailbox_new creates a new mailbox identified by
43 * the key specified by the parameter alias and add it in the global
44 * dictionary but doesn't add it in the global dictionary. Typicaly,
45 * this type of mailbox is associated with a channel.
47 * \param alias The alias of the mailbox to create.
49 * \return The newly created mailbox.
51 msg_mailbox_t MSG_mailbox_create(const char *alias);
53 /* \brief MSG_mailbox_free - release a mailbox from the memory.
55 * The function MSG_mailbox_free release a mailbox from the memory but does
56 * not remove it from the dictionary.
58 * \param mailbox The mailbox to release.
60 * \see MSG_mailbox_destroy.
62 void MSG_mailbox_free(void *mailbox);
64 /* \brief MSG_mailbox_get_by_alias - get a mailbox from its alias.
66 * The function MSG_mailbox_get_by_alias returns the mailbox associated with
67 * the key specified by the parameter alias. If the mailbox does not exists,
68 * the function create it.
70 * \param alias The alias of the mailbox to return.
72 * \return The mailbox associated with the alias specified as parameter
73 * or a new mailbox if the key does not match.
75 XBT_PUBLIC(msg_mailbox_t)
76 MSG_mailbox_get_by_alias(const char *alias);
78 /* \brief MSG_mailbox_get_by_channel - get a mailbox of the specified host from its channel.
80 * The function MSG_mailbox_get_by_channel returns the mailbox of the
81 * specified host from the channel specified by the parameter
82 * channel. If the mailbox does not exists, the function fails.
84 * \param host The host containing he mailbox to get.
85 * \param channel The channel used to identify the mailbox.
87 * \return The mailbox of the specified host associated the channel
88 * specified as parameter.
91 XBT_PUBLIC(msg_mailbox_t)
92 MSG_mailbox_get_by_channel(m_host_t host, m_channel_t channel);
94 /*! \brief MSG_mailbox_get_alias - get the alias associated with the mailbox.
96 * The function MSG_mailbox_get_alias returns the alias of the mailbox specified
97 * by the parameter mailbox.
99 * \param mailbox The mailbox to get the alias.
101 * \return The alias of the mailbox specified by the parameter mailbox.
103 XBT_PUBLIC(const char *) MSG_mailbox_get_alias(msg_mailbox_t mailbox);
105 /*! \brief MSG_mailbox_get_cond - get the simix condition of a mailbox.
107 * The function MSG_mailbox_get_cond returns the condition of the
108 * mailbox specified by the parameter mailbox.
110 * \param mailbox The mailbox to get the condition.
112 * \return The simix condition of the mailbox specified by the parameter mailbox.
114 XBT_PUBLIC(smx_cond_t)
115 MSG_mailbox_get_cond(msg_mailbox_t mailbox);
117 /*! \brief MSG_mailbox_set_cond - set the simix condition of a mailbox.
119 * The function MSG_mailbox_set_cond set the condition of the mailbox
120 * specified by the parameter mailbox.
122 * \param mailbox The mailbox to set the condition.
123 * \param cond The new simix condition of the mailbox.
126 XBT_PUBLIC(void) MSG_mailbox_set_cond(msg_mailbox_t mailbox,
129 /*! \brief MSG_mailbox_is_empty - test if a mailbox is empty.
131 * The function MSG_mailbox_is_empty tests if a mailbox is empty
132 * (contains no msg task).
134 * \param mailbox The mailbox to get test.
136 * \return The function returns 1 if the mailbox is empty. Otherwise the function
139 XBT_PUBLIC(int) MSG_mailbox_is_empty(msg_mailbox_t mailbox);
141 /*! \brief MSG_mailbox_get_head - get the task at the head of a mailbox.
143 * The MSG_mailbox_get_head returns the task at the head of the mailbox.
144 * This function does not remove the task from the mailbox (contrary to
145 * the function MSG_mailbox_pop_head).
147 * \param mailbox The mailbox concerned by the operation.
149 * \return The task at the head of the mailbox.
152 MSG_mailbox_get_head(msg_mailbox_t mailbox);
154 /*! \brief MSG_mailbox_get_count_host_waiting_tasks - Return the number of tasks
155 waiting to be received in a mailbox and sent by a host.
157 * \param mailbox The mailbox concerned by the operation.
158 * \param host The msg host containing the processes that have sended the
161 * \return The number of tasks in the mailbox specified by the
162 * parameter mailbox and sended by all the processes located
163 * on the host specified by the parameter host.
166 MSG_mailbox_get_count_host_waiting_tasks(msg_mailbox_t mailbox,
171 #endif /* !SMX_MAILBOX_H */