9 XBT_LOG_EXTERNAL_DEFAULT_CATEGORY(main);
11 std::vector<hostdata> hostdata::hosts;
13 // used to compare m_host_t's by name
14 struct hostdata::m_host_less {
15 bool operator()(const m_host_t& a, const m_host_t& b)
17 const char* na = MSG_host_get_name(a);
18 const char* nb = MSG_host_get_name(b);
19 return strcmp(na, nb) < 0;
23 void hostdata::create()
25 int nhosts = MSG_get_host_number();
26 m_host_t* host_list = MSG_get_host_table();
27 // fixme: only sort hosts for automatically created deployment
28 // fixme: add an option to disable sorting
29 std::sort(host_list, host_list + nhosts, m_host_less());
30 hosts.assign(host_list, host_list + nhosts);
33 e_xbt_log_priority_t logp = xbt_log_priority_verbose;
34 if (!LOG_ISENABLED(logp))
36 LOG1(logp, "Got %lu hosts.", (unsigned long)hosts.size());
37 for (int i = 0; i < nhosts; i++) {
38 LOG2(logp, "Host #%d named \"%s\".", i, hosts[i].get_name());
42 void hostdata::destroy()
44 // hosts are automatically destroyed...
47 hostdata::hostdata(m_host_t host)
48 : name(MSG_host_get_name(host))
49 , ctrl_mbox(std::string(name) + "_ctrl")
50 , data_mbox(std::string(name) + "_data")
52 MSG_host_set_data(host, this);