+ DEBUG1
+ ("MSG_task_receive_ext: Trying to receive a message on mailbox '%s'",
+ alias);
+ return MSG_mailbox_get_task_ext(MSG_mailbox_get_by_alias(alias), task,
+ host, timeout);
+}
+
+/** \ingroup msg_gos_functions
+ * \brief Send a task on a channel.
+ *
+ * This function takes two parameter.
+ * \param task a #m_task_t to send on another location.
+ * \param alias the channel on which the agent should put this
+ task. This value has to be >=0 and < than the maximal number of
+ channels fixed with MSG_set_channel_number().
+ * \return the msg_comm_t communication.
+ */
+msg_comm_t MSG_task_isend(m_task_t task, const char *alias)
+{
+ simdata_task_t t_simdata = NULL;
+ m_process_t process = MSG_process_self();
+ msg_mailbox_t mailbox = MSG_mailbox_get_by_alias(alias);
+
+ CHECK_HOST();
+
+ /* FIXME: these functions are not tracable */
+
+ /* Prepare the task to send */
+ t_simdata = task->simdata;
+ t_simdata->sender = process;
+ t_simdata->source = MSG_host_self();
+
+ xbt_assert0(t_simdata->isused == 0,
+ "This task is still being used somewhere else. You cannot send it now. Go fix your code!");
+
+ t_simdata->isused=1;
+ msg_global->sent_msg++;
+
+ /* Send it by calling SIMIX network layer */
+ t_simdata->comm =
+ SIMIX_req_comm_isend(mailbox, t_simdata->message_size,
+ t_simdata->rate, task, sizeof(void *), NULL, NULL);
+ return t_simdata->comm;
+}
+
+/** \ingroup msg_gos_functions
+ * \brief Listen on a channel for receiving a task from an asynchronous communication.
+ *
+ * It takes two parameters.
+ * \param task a memory location for storing a #m_task_t.
+ * \param alias the channel on which the agent should be
+ listening. This value has to be >=0 and < than the maximal
+ number of channels fixed with MSG_set_channel_number().
+ * \return the msg_comm_t communication.
+ */
+msg_comm_t MSG_task_irecv(m_task_t * task, const char *alias)
+{
+ smx_rdv_t rdv = MSG_mailbox_get_by_alias(alias);
+
+ CHECK_HOST();
+
+ /* FIXME: these functions are not tracable */
+
+ /* Sanity check */
+ xbt_assert0(task, "Null pointer for the task storage");
+
+ if (*task)
+ CRITICAL0
+ ("MSG_task_get() was asked to write in a non empty task struct.");
+
+ /* Try to receive it by calling SIMIX network layer */
+ return SIMIX_req_comm_irecv(rdv, task, NULL, NULL, NULL);
+}
+
+/** \ingroup msg_gos_functions
+ * \brief Returns whether a communication is finished.
+ * \param comm the communication to test
+ * \return TRUE if the communication is finished
+ * (but it may have failed, use MSG_comm_get_status() to know its status)
+ * or FALSE if the communication is not finished yet
+ * If the status is FALSE, don't forget to use MSG_process_sleep() after the test.
+ */
+int MSG_comm_test(msg_comm_t comm)
+{
+ xbt_ex_t e;
+ int finished = 0;
+ TRY {
+ finished = SIMIX_req_comm_test(comm);
+ }
+ CATCH(e) {
+ switch (e.category) {
+
+ case host_error:
+ case network_error:
+ case timeout_error:
+ finished = 1;
+ break;
+
+ default:
+ RETHROW;
+ }
+ xbt_ex_free(e);
+ }
+ return finished;
+}
+
+/** \ingroup msg_gos_functions
+ * \brief This function checks if a communication is finished
+ * \param comms a vector of communications
+ * \return the position of the finished communication if any
+ * (but it may have failed, use MSG_comm_get_status() to know its status),
+ * or -1 if none is finished
+ */
+int MSG_comm_testany(xbt_dynar_t comms)
+{
+ xbt_ex_t e;
+ int finished_index = -1;
+ TRY {
+ finished_index = SIMIX_req_comm_testany(comms);
+ }
+ CATCH(e) {
+ switch (e.category) {
+
+ case host_error:
+ case network_error:
+ case timeout_error:
+ finished_index = e.value;
+ break;
+
+ default:
+ RETHROW;
+ }
+ xbt_ex_free(e);
+ }
+ return finished_index;
+}
+
+/** \ingroup msg_gos_functions
+ * \brief After received TRUE to MSG_comm_test(), the communication should be destroyed.
+ *
+ * It takes one parameter.
+ * \param comm the communication to destroy.
+ */
+void MSG_comm_destroy(msg_comm_t comm)
+{
+ if (SIMIX_req_comm_get_src_proc(comm) != SIMIX_process_self()) {
+ m_task_t task;
+ task = (m_task_t) SIMIX_req_comm_get_src_buff(comm);
+ task->simdata->isused=0;
+ }
+ SIMIX_req_comm_destroy(comm);