5 #include <xbt/sysdep.h>
7 XBT_LOG_EXTERNAL_DEFAULT_CATEGORY(main);
14 std::vector<hostdata> hostdata::hosts;
16 void hostdata::create()
18 xbt_dynar_t host_dynar = MSG_hosts_as_dynar();
19 int nhosts = xbt_dynar_length(host_dynar);
20 msg_host_t* host_list = static_cast<msg_host_t*>(xbt_dynar_to_array(host_dynar));
21 // only sort hosts for automatically created deployment
22 if (opt::auto_depl::enabled)
23 std::sort(host_list, host_list + nhosts,
24 [](msg_host_t a, msg_host_t b) {
25 return std::strcmp(MSG_host_get_name(a), MSG_host_get_name(b)) < 0;
27 hosts.assign(host_list, host_list + nhosts);
30 e_xbt_log_priority_t logp = xbt_log_priority_verbose;
31 if (!LOG_ISENABLED(logp))
33 XBT_LOG(logp, "Got %zu hosts.", hosts.size());
34 for (int i = 0; i < nhosts; i++) {
35 XBT_LOG(logp, "Host #%d named \"%s\".", i, hosts[i].get_name());
39 void hostdata::destroy()
41 // hosts are automatically destroyed...
44 hostdata::hostdata(msg_host_t host)
45 : name(MSG_host_get_name(host))
46 , ctrl_mbox(std::string(name) + "_ctrl")
47 , data_mbox(std::string(name) + "_data")
49 MSG_host_set_data(host, this);