- return SIMIX_network_test(comm);
-}
-MSG_error_t MSG_comm_wait(msg_comm_t comm,double timeout) {
- xbt_ex_t e;
- MSG_error_t res = MSG_OK;
- TRY {
- SIMIX_network_wait(comm,timeout);
- // (*task)->simdata->refcount--;
-
- /* FIXME: these functions are not tracable */
- } CATCH(e){
- switch(e.category){
- case host_error:
- res = MSG_HOST_FAILURE;
- break;
- case network_error:
- res = MSG_TRANSFER_FAILURE;
- break;
- case timeout_error:
- res = MSG_TIMEOUT;
- break;
- default:
- xbt_die(bprintf("Unhandled SIMIX network exception: %s",e.msg));
- }
- xbt_ex_free(e);
- }
- return res;
+ return SIMIX_network_test(comm);
+}
+/** \ingroup msg_gos_functions
+ * \brief After received TRUE to MSG_comm_test(), the communication must be destroyed.
+ *
+ * It takes one parameter.
+ * \param comm the communication to destroy.
+ */
+void MSG_comm_destroy(msg_comm_t comm) {
+ if(!(comm->src_proc == SIMIX_process_self()))
+ {
+ m_task_t task;
+ task = (m_task_t) SIMIX_communication_get_src_buf(comm);
+ task->simdata->refcount--;
+ }
+ SIMIX_communication_destroy(comm);
+}
+
+/** \ingroup msg_gos_functions
+ * \brief Wait for the completion of a communication.
+ *
+ * It takes two parameters.
+ * \param comm the communication to wait.
+ * \param timeout Wait until the communication terminates or the timeout occurs
+ * \return MSG_error_t
+ */
+MSG_error_t MSG_comm_wait(msg_comm_t comm, double timeout) {
+ xbt_ex_t e;
+ MSG_error_t res = MSG_OK;
+ TRY {
+ SIMIX_network_wait(comm,timeout);
+
+ if(!(comm->src_proc == SIMIX_process_self()))
+ {
+ m_task_t task;
+ task = (m_task_t) SIMIX_communication_get_src_buf(comm);
+ task->simdata->refcount--;
+ }
+
+ /* FIXME: these functions are not tracable */
+ } CATCH(e){
+ switch(e.category){
+ case host_error:
+ res = MSG_HOST_FAILURE;
+ break;
+ case network_error:
+ res = MSG_TRANSFER_FAILURE;
+ break;
+ case timeout_error:
+ res = MSG_TIMEOUT;
+ break;
+ default:
+ xbt_die(bprintf("Unhandled SIMIX network exception: %s",e.msg));
+ }
+ xbt_ex_free(e);
+ }
+ return res;
+}
+
+/** \ingroup msg_gos_functions
+* \brief This function is called by a sender and permit to wait for each communication
+*
+* It takes three parameters.
+* \param comm a vector of communication
+* \param nb_elem is the size of the comm vector
+* \param timeout for each call of MSG_comm_wait
+*/
+void MSG_comm_waitall(msg_comm_t *comm,int nb_elem, double timeout) {
+ int i=0;
+ for(i=0; i<nb_elem; i++)
+ {
+ MSG_comm_wait(comm[i],timeout);
+ }
+}
+/** \ingroup msg_gos_functions
+* \brief This function wait for the first completed communication
+*
+* It takes on parameter.
+* \param comms a vector of communication
+* \return the position of the completed communication from the xbt_dynar_t.
+*/
+int MSG_comm_waitany(xbt_dynar_t comms) {
+ return SIMIX_network_waitany(comms);
+}
+
+m_task_t MSG_comm_get_task(msg_comm_t comm) {
+ xbt_assert0(comm, "Invalid parameters");
+ return (m_task_t) SIMIX_communication_get_src_buf(comm);