+ msg_error_t ret = MSG_OK;
+ simdata_task_t t_simdata = nullptr;
+ msg_process_t process = MSG_process_self();
+ simgrid::s4u::MailboxPtr mailbox = simgrid::s4u::Mailbox::by_name(alias);
+
+ TRACE_msg_task_put_start(task);
+
+ /* Prepare the task to send */
+ t_simdata = task->simdata;
+ t_simdata->sender = process;
+ t_simdata->source = MSG_host_self();
+
+ t_simdata->setUsed();
+
+ t_simdata->comm = nullptr;
+ msg_global->sent_msg++;
+
+ /* Try to send it by calling SIMIX network layer */
+ try {
+ simgrid::s4u::CommPtr comm = mailbox->put_init(task, t_simdata->bytes_amount)->set_rate(t_simdata->rate);
+ t_simdata->comm = boost::static_pointer_cast<simgrid::kernel::activity::CommImpl>(comm->get_impl());
+ comm->start();
+ if (TRACE_is_enabled() && task->category != nullptr)
+ simgrid::simix::simcall([comm, task] { comm->get_impl()->set_category(task->category); });
+ comm->wait_for(timeout);
+ } catch (simgrid::TimeoutError& e) {
+ ret = MSG_TIMEOUT;
+ } catch (simgrid::CancelException& e) {
+ ret = MSG_HOST_FAILURE;
+ } catch (xbt_ex& e) {
+ if (e.category == network_error)
+ ret = MSG_TRANSFER_FAILURE;
+ else
+ throw;
+
+ /* If the send failed, it is not used anymore */
+ t_simdata->setNotUsed();
+ }
+
+ return ret;