-/** \ingroup msg_task_usage
- * \brief Check if there is a communication going on in a mailbox.
- *
- * \param alias the name of the mailbox to be considered
- *
- * \return Returns 1 if there is a communication, 0 otherwise
- */
-int MSG_task_listen(const char *alias)
-{
- return !MSG_mailbox_is_empty(MSG_mailbox_get_by_alias(alias));
+ /* 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 {
+ 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->get_impl(), t_simdata->bytes_amount, t_simdata->rate, task,
+ sizeof(void*), nullptr, nullptr, nullptr, nullptr, 0);
+ if (TRACE_is_enabled() && task->category != nullptr)
+ simcall_set_category(comm, task->category);
+ t_simdata->comm = boost::static_pointer_cast<simgrid::kernel::activity::CommImpl>(comm);
+ simcall_comm_wait(comm, timeout);
+ } catch (simgrid::TimeoutError& e) {
+ ret = MSG_TIMEOUT;
+ }
+ catch (xbt_ex& e) {
+ switch (e.category) {
+ case cancel_error:
+ ret = MSG_HOST_FAILURE;
+ break;
+ case network_error:
+ ret = MSG_TRANSFER_FAILURE;
+ break;
+ default:
+ throw;
+ }
+
+ /* If the send failed, it is not used anymore */
+ t_simdata->setNotUsed();
+ }
+
+ TRACE_msg_task_put_end();
+ return ret;