static int receiver_fun(int argc, char *argv[]) { XBT_INFO("Receiving"); msg_task_t task = NULL; MSG_task_receive_with_timeout(&task, MSG_host_get_name(MSG_host_self()), DBL_MAX); xbt_assert(MSG_task_get_sender(task), "No sender received"); XBT_INFO("Got a message sent by '%s'", MSG_process_get_name(MSG_task_get_sender(task))); MSG_task_destroy(task); return 0; }
/** \ingroup msg_task_usage * \brief Receives a task from a mailbox. * * This is a blocking function, the execution flow will be blocked * until the task is received. See #MSG_task_irecv * for receiving tasks asynchronously. * * \param task a memory location for storing a #msg_task_t. * \param alias name of the mailbox to receive the task from * * \return Returns * #MSG_OK if the task was successfully received, * #MSG_HOST_FAILURE, or #MSG_TRANSFER_FAILURE otherwise. */ msg_error_t MSG_task_receive(msg_task_t * task, const char *alias) { return MSG_task_receive_with_timeout(task, alias, -1); }