+ msg_error_t ret = MSG_OK;
+ /* We no longer support getting a task from a specific host */
+ if (host)
+ THROW_UNIMPLEMENTED;
+
+ /* Sanity check */
+ xbt_assert(task, "Null pointer for the task storage");
+
+ if (*task)
+ XBT_WARN("Asked to write the received task in a non empty struct -- proceeding.");
+
+ /* Try to receive it by calling SIMIX network layer */
+ try {
+ void* payload;
+ simgrid::s4u::Mailbox::by_name(alias)
+ ->get_init()
+ ->set_dst_data(&payload, sizeof(msg_task_t*))
+ ->set_rate(rate)
+ ->wait_for(timeout);
+ *task = static_cast<msg_task_t>(payload);
+ XBT_DEBUG("Got task %s from %s", (*task)->name, alias);
+ (*task)->simdata->set_not_used();
+ } catch (simgrid::HostFailureException& e) {
+ ret = MSG_HOST_FAILURE;
+ } catch (simgrid::TimeoutError& e) {
+ ret = MSG_TIMEOUT;
+ } catch (simgrid::CancelException& e) {
+ ret = MSG_TASK_CANCELED;
+ } catch (xbt_ex& e) {
+ if (e.category == network_error)
+ ret = MSG_TRANSFER_FAILURE;
+ else
+ throw;
+ }
+
+ if (TRACE_actor_is_enabled() && ret != MSG_HOST_FAILURE && ret != MSG_TRANSFER_FAILURE && ret != MSG_TIMEOUT) {
+ container_t process_container = simgrid::instr::Container::by_name(instr_pid(MSG_process_self()));
+
+ std::string key = std::string("p") + std::to_string((*task)->counter);
+ simgrid::instr::Container::get_root()->get_link("ACTOR_TASK_LINK")->end_event(process_container, "SR", key);
+ }
+ return ret;