+ msg_error_t ret = MSG_OK;
+ simdata_task_t t_simdata = nullptr;
+ msg_process_t process = MSG_process_self();
+ simdata_process_t p_simdata = static_cast<simdata_process_t>(SIMIX_process_self_get_data());
+ simgrid::s4u::MailboxPtr mailbox = simgrid::s4u::Mailbox::byName(alias);
+
+ int call_end = TRACE_msg_task_put_start(task); //must be after CHECK_HOST()
+
+ /* Prepare the task to send */
+ t_simdata = task->simdata;
+ t_simdata->sender = process;
+ t_simdata->source = (static_cast<simdata_process_t>(SIMIX_process_self_get_data())) ->m_host;
+
+ t_simdata->setUsed();
+
+ t_simdata->comm = nullptr;
+ msg_global->sent_msg++;
+
+ p_simdata->waiting_task = task;
+
+ /* Try to send it by calling SIMIX network layer */
+ try {
+ smx_activity_t comm = nullptr; /* MC needs the comm to be set to nullptr during the simix call */
+ comm = simcall_comm_isend(SIMIX_process_self(), mailbox->getImpl(),t_simdata->bytes_amount,
+ t_simdata->rate, task, sizeof(void *), nullptr, nullptr, nullptr, task, 0);
+ if (TRACE_is_enabled())
+ simcall_set_category(comm, task->category);
+ t_simdata->comm = static_cast<simgrid::kernel::activity::Comm*>(comm);
+ simcall_comm_wait(comm, timeout);
+ }
+ catch (xbt_ex& e) {
+ switch (e.category) {
+ case cancel_error:
+ ret = MSG_HOST_FAILURE;
+ break;
+ case network_error:
+ ret = MSG_TRANSFER_FAILURE;
+ break;
+ case timeout_error:
+ ret = MSG_TIMEOUT;
+ break;
+ default:
+ throw;
+ }
+
+ /* If the send failed, it is not used anymore */
+ t_simdata->setNotUsed();
+ }
+
+ p_simdata->waiting_task = nullptr;
+ if (call_end)
+ TRACE_msg_task_put_end();
+ return ret;