+ action->comm.surf_comm->model_type->action_unref(action->comm.surf_comm);
+ action->comm.surf_comm = NULL;
+ }
+
+ if (action->comm.src_timeout){
+ action->comm.src_timeout->model_type->action_unref(action->comm.src_timeout);
+ action->comm.src_timeout = NULL;
+ }
+
+ if (action->comm.dst_timeout){
+ action->comm.dst_timeout->model_type->action_unref(action->comm.dst_timeout);
+ action->comm.dst_timeout = NULL;
+ }
+}
+
+smx_action_t SIMIX_comm_isend(smx_process_t src_proc, smx_rdv_t rdv,
+ double task_size, double rate,
+ void *src_buff, size_t src_buff_size,
+ int (*match_fun)(void *, void *), void *data,
+ int detached)
+{
+ smx_action_t action;
+
+ /* Look for communication request matching our needs.
+ If it is not found then create it and push it into the rendez-vous point */
+ action = SIMIX_rdv_get_request(rdv, SIMIX_COMM_RECEIVE, match_fun, data);
+
+ if (!action) {
+ action = SIMIX_comm_new(SIMIX_COMM_SEND);
+ SIMIX_rdv_push(rdv, action);
+ } else {
+ action->state = SIMIX_READY;
+ action->comm.type = SIMIX_COMM_READY;
+ }
+ xbt_fifo_push(src_proc->comms, action);
+
+ /* if the communication action is detached then decrease the refcount
+ * by one, so it will be eliminated by the receiver's destroy call */
+ if (detached) {
+ action->comm.detached = 1;
+ action->comm.refcount--;
+ }
+
+ /* Setup the communication request */
+ action->comm.src_proc = src_proc;
+ action->comm.task_size = task_size;
+ action->comm.rate = rate;
+ action->comm.src_buff = src_buff;
+ action->comm.src_buff_size = src_buff_size;
+ action->comm.src_data = data;
+
+ if (MC_IS_ENABLED) {
+ action->state = SIMIX_RUNNING;
+ return action;
+ }
+
+ SIMIX_comm_start(action);
+ return action;
+}
+
+smx_action_t SIMIX_comm_irecv(smx_process_t dst_proc, smx_rdv_t rdv,
+ void *dst_buff, size_t *dst_buff_size,
+ int (*match_fun)(void *, void *), void *data)
+{
+ smx_action_t action;
+
+ /* Look for communication request matching our needs.
+ * If it is not found then create it and push it into the rendez-vous point
+ */
+ action = SIMIX_rdv_get_request(rdv, SIMIX_COMM_SEND, match_fun, data);
+
+ if (!action) {
+ action = SIMIX_comm_new(SIMIX_COMM_RECEIVE);
+ SIMIX_rdv_push(rdv, action);
+ } else {
+ action->state = SIMIX_READY;
+ action->comm.type = SIMIX_COMM_READY;
+ }
+ xbt_fifo_push(dst_proc->comms, action);