+ /* 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;
+ }
+
+ /* If the communication action is detached then decrease the refcount
+ * by one, so it will be eliminated by the receivers 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;
+ }
+
+ /* Setup communication request */
+ action->comm.dst_proc = dst_proc;
+ action->comm.dst_buff = dst_buff;
+ action->comm.dst_buff_size = dst_buff_size;
+ action->comm.dst_data = data;
+
+ if (MC_IS_ENABLED) {
+ action->state = SIMIX_RUNNING;
+ return action;
+ }
+
+ SIMIX_comm_start(action);
+ return action;
+}
+
+void SIMIX_pre_comm_wait(smx_req_t req, smx_action_t action, double timeout, int idx)
+{
+ /* the request may be a wait, a send or a recv */
+ surf_action_t sleep;
+
+ /* Associate this request to the action */
+ xbt_fifo_push(action->request_list, req);
+ req->issuer->waiting_action = action;
+
+ if (MC_IS_ENABLED) {
+ if (idx == 0) {
+ action->state = SIMIX_DONE;
+ } else {
+ /* If we reached this point, the wait request must have a timeout */
+ /* Otherwise it shouldn't be enabled and executed by the MC */
+ if (timeout == -1)
+ THROW_IMPOSSIBLE;
+
+ if (action->comm.src_proc == req->issuer)
+ action->state = SIMIX_SRC_TIMEOUT;
+ else
+ action->state = SIMIX_DST_TIMEOUT;