+
+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 *,smx_action_t),
+ void (*clean_fun)(void *), // used to free the action in case of problem after a detached send
+ void *data,
+ int detached)
+{
+ /* Prepare an action describing us, so that it gets passed to the user-provided filter of other side */
+ smx_action_t this_action = SIMIX_comm_new(SIMIX_COMM_SEND);
+
+ /* Look for communication action matching our needs. We also provide a description of
+ * ourself so that the other side also gets a chance of choosing if it wants to match with us.
+ *
+ * If it is not found then push our communication into the rendez-vous point */
+ smx_action_t other_action = SIMIX_rdv_get_comm(rdv, SIMIX_COMM_RECEIVE, match_fun, data, this_action);
+
+ if (!other_action) {
+ other_action = this_action;
+ SIMIX_rdv_push(rdv, this_action);
+ } else {
+ SIMIX_comm_destroy(this_action);
+ --smx_total_comms; // this creation was a pure waste
+
+ other_action->state = SIMIX_READY;
+ other_action->comm.type = SIMIX_COMM_READY;
+ }
+ xbt_fifo_push(src_proc->comms, other_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) {
+ other_action->comm.detached = 1;
+ other_action->comm.refcount--;
+ other_action->comm.clean_fun = clean_fun;
+ } else {
+ other_action->comm.clean_fun = NULL;
+ }
+
+ /* Setup the communication action */
+ other_action->comm.src_proc = src_proc;
+ other_action->comm.task_size = task_size;
+ other_action->comm.rate = rate;
+ other_action->comm.src_buff = src_buff;
+ other_action->comm.src_buff_size = src_buff_size;
+ other_action->comm.src_data = data;
+
+ other_action->comm.match_fun = match_fun;
+
+ if (MC_IS_ENABLED) {
+ other_action->state = SIMIX_RUNNING;
+ return other_action;
+ }
+
+ SIMIX_comm_start(other_action);
+ return (detached ? NULL : other_action);