1 /* Copyright (c) 2008-2013. 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 "simgrid/simix.h"
12 #include "msg/datatypes.h"
16 #define MAX_ALIAS_NAME ((size_t)260)
18 /*! \brief MSG_mailbox_new - create a new mailbox.
20 * The function MSG_mailbox_new creates a new mailbox identified by the key specified
21 * by the parameter alias and add it in the global dictionary.
23 * \param alias The alias of the mailbox to create.
25 * \return The newly created mailbox.
27 XBT_PUBLIC(msg_mailbox_t)
28 MSG_mailbox_new(const char *alias);
30 void MSG_mailbox_free(void *mailbox);
32 /* \brief MSG_mailbox_free - release a mailbox from the memory.
34 * The function MSG_mailbox_free release a mailbox from the memory but does
35 * not remove it from the dictionary.
37 * \param mailbox The mailbox to release.
39 * \see MSG_mailbox_destroy.
41 void MSG_mailbox_free(void *mailbox);
43 /* \brief MSG_mailbox_get_by_alias - get a mailbox from its alias.
45 * The function MSG_mailbox_get_by_alias returns the mailbox associated with
46 * the key specified by the parameter alias. If the mailbox does not exists,
47 * the function create it.
49 * \param alias The alias of the mailbox to return.
51 * \return The mailbox associated with the alias specified as parameter
52 * or a new mailbox if the key does not match.
54 XBT_PUBLIC(msg_mailbox_t)
55 MSG_mailbox_get_by_alias(const char *alias);
57 /*! \brief MSG_mailbox_is_empty - test if a mailbox is empty.
59 * The function MSG_mailbox_is_empty tests if a mailbox is empty
60 * (contains no msg task).
62 * \param mailbox The mailbox to get test.
64 * \return The function returns 1 if the mailbox is empty. Otherwise the function
67 XBT_PUBLIC(int) MSG_mailbox_is_empty(msg_mailbox_t mailbox);
69 /* \brief MSG_mailbox_set_async - set a mailbox as eager
71 * The function MSG_mailbox_set_async sets the mailbox to a permanent receiver mode
72 * Messages sent to this mailbox will then be sent just after the send is issued,
73 * without waiting for the corresponding receive.
75 * This call should be done before issuing any receive, and on the receiver's side only
77 * \param alias The alias of the mailbox to modify.
80 XBT_PUBLIC(void) MSG_mailbox_set_async(const char *alias);
82 /*! \brief MSG_mailbox_get_head - get the task at the head of a mailbox.
84 * The MSG_mailbox_get_head returns the task at the head of the mailbox.
85 * This function does not remove the task from the mailbox (contrary to
86 * the function MSG_mailbox_pop_head).
88 * \param mailbox The mailbox concerned by the operation.
90 * \return The task at the head of the mailbox.
92 XBT_PUBLIC(msg_task_t)
93 MSG_mailbox_get_head(msg_mailbox_t mailbox);
95 /*! \brief MSG_mailbox_get_count_host_waiting_tasks - Return the number of tasks
96 waiting to be received in a mailbox and sent by a host.
98 * \param mailbox The mailbox concerned by the operation.
99 * \param host The msg host containing the processes that have sended the
102 * \return The number of tasks in the mailbox specified by the
103 * parameter mailbox and sended by all the processes located
104 * on the host specified by the parameter host.
107 MSG_mailbox_get_count_host_waiting_tasks(msg_mailbox_t mailbox,
110 #ifdef MSG_USE_DEPRECATED
111 /* \brief MSG_mailbox_get_by_channel - get a mailbox of the specified host from its channel.
113 * The function MSG_mailbox_get_by_channel returns the mailbox of the
114 * specified host from the channel specified by the parameter
115 * channel. If the mailbox does not exists, the function fails.
117 * \param host The host containing he mailbox to get.
118 * \param channel The channel used to identify the mailbox.
120 * \return The mailbox of the specified host associated the channel
121 * specified as parameter.
124 XBT_PUBLIC(msg_mailbox_t)
125 MSG_mailbox_get_by_channel(msg_host_t host, m_channel_t channel);
129 #endif /* !MSG_MAILBOX_H */