+ * \brief This function waits for the first communication finished in a list.
+ * \param comms a vector of communications
+ * \return the position of the first finished communication
+ * (but it may have failed, use MSG_comm_get_status() to know its status)
+ */
+int MSG_comm_waitany(xbt_dynar_t comms)
+{
+ xbt_ex_t e;
+ int finished_index = -1;
+
+ /* create the equivalent dynar with SIMIX objects */
+ xbt_dynar_t s_comms = xbt_dynar_new(sizeof(smx_action_t), NULL);
+ msg_comm_t comm;
+ unsigned int cursor;
+ xbt_dynar_foreach(comms, cursor, comm) {
+ xbt_dynar_push(s_comms, &comm->s_comm);
+ }
+
+ MSG_error_t status = MSG_OK;
+ TRY {
+ finished_index = SIMIX_req_comm_waitany(s_comms);
+ }
+ CATCH(e) {
+ switch (e.category) {
+
+ case host_error:
+ finished_index = e.value;
+ status = MSG_HOST_FAILURE;
+ break;
+
+ case network_error:
+ finished_index = e.value;
+ status = MSG_TRANSFER_FAILURE;
+ break;
+
+ case timeout_error:
+ finished_index = e.value;
+ status = MSG_TIMEOUT;
+ break;
+
+ default:
+ RETHROW;
+ }
+ xbt_ex_free(e);
+ }
+
+ xbt_assert(finished_index != -1, "WaitAny returned -1");
+ xbt_dynar_free(&s_comms);
+
+ comm = xbt_dynar_get_as(comms, finished_index, msg_comm_t);
+ /* the communication is finished */
+ comm->status = status;
+
+ return finished_index;
+}
+
+/**
+ * \ingroup msg_gos_functions
+ * \brief Returns the error (if any) that occured during a finished communication.
+ * \param comm a finished communication
+ * \return the status of the communication, or MSG_OK if no error occured
+ * during the communication
+ */
+MSG_error_t MSG_comm_get_status(msg_comm_t comm) {
+
+ return comm->status;
+}
+
+m_task_t MSG_comm_get_task(msg_comm_t comm)
+{
+ xbt_assert(comm, "Invalid parameter");
+
+ return comm->task_received ? *comm->task_received : comm->task_sent;
+}
+
+/** \ingroup msg_gos_functions
+ * \brief Put a task on a channel of an host and waits for the end of the
+ * transmission.
+ *
+ * This function is used for describing the behavior of an agent. It
+ * takes three parameter.
+ * \param task a #m_task_t to send on another location. This task
+ will not be usable anymore when the function will return. There is
+ no automatic task duplication and you have to save your parameters
+ before calling this function. Tasks are unique and once it has been
+ sent to another location, you should not access it anymore. You do
+ not need to call MSG_task_destroy() but to avoid using, as an
+ effect of inattention, this task anymore, you definitely should
+ renitialize it with #MSG_TASK_UNINITIALIZED. Note that this task
+ can be transfered iff it has been correctly created with
+ MSG_task_create().
+ * \param dest the destination of the message
+ * \param channel 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 #MSG_FATAL if \a task is not properly initialized and
+ * #MSG_OK otherwise. Returns #MSG_HOST_FAILURE if the host on which
+ * this function was called was shut down. Returns
+ * #MSG_TRANSFER_FAILURE if the transfer could not be properly done
+ * (network failure, dest failure)
+ */
+MSG_error_t MSG_task_put(m_task_t task, m_host_t dest, m_channel_t channel)
+{
+ return MSG_task_put_with_timeout(task, dest, channel, -1.0);
+}
+
+/** \ingroup msg_gos_functions
+ * \brief Does exactly the same as MSG_task_put but with a bounded transmition