+ DEBUG1("Destroy action %p", action);
+
+ if (action->comm.refcount <= 0)
+ xbt_die(bprintf("the refcount of comm %p is already 0 before decreasing it. That's a bug!",action));
+
+#ifdef HAVE_LATENCY_BOUND_TRACKING
+ //save is latency limited flag to use afterwards
+ if (action->comm.surf_comm) {
+ DEBUG2("adding key %p with latency limited value %d to the dict", action,
+ SIMIX_comm_is_latency_bounded(action));
+ xbt_dicti_set(simix_global->latency_limited_dict, (uintptr_t) action,
+ SIMIX_comm_is_latency_bounded(action));
+ }
+#endif
+
+ action->comm.refcount--;
+ if (action->comm.refcount > 0)
+ return;
+ VERB2("Really free communication %p; refcount is now %d", action,
+ action->comm.refcount);
+
+#ifdef HAVE_TRACING
+ TRACE_smx_action_destroy(action);
+#endif
+
+ if (action->name)
+ xbt_free(action->name);
+
+ xbt_fifo_free(action->request_list);
+
+ SIMIX_comm_destroy_internal_actions(action);
+
+ xbt_free(action);
+}
+
+void SIMIX_comm_destroy_internal_actions(smx_action_t action)
+{
+ if (action->comm.surf_comm){
+ 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)
+{
+ 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;
+ }
+
+ /* 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