7 #include <xbt/sysdep.h>
11 XBT_LOG_EXTERNAL_DEFAULT_CATEGORY(main);
13 std::vector<hostdata> hostdata::hosts;
15 // used to compare m_host_t's by name
16 struct hostdata::m_host_less {
17 bool operator()(const m_host_t& a, const m_host_t& b)
19 const char* na = MSG_host_get_name(a);
20 const char* nb = MSG_host_get_name(b);
21 return strcmp(na, nb) < 0;
25 void hostdata::create()
27 int nhosts = MSG_get_host_number();
28 m_host_t* host_list = MSG_get_host_table();
29 // only sort hosts for automatically created deployment
30 if (opt::auto_depl::enabled)
31 std::sort(host_list, host_list + nhosts, m_host_less());
32 hosts.assign(host_list, host_list + nhosts);
35 e_xbt_log_priority_t logp = xbt_log_priority_verbose;
36 if (!LOG_ISENABLED(logp))
38 LOG1(logp, "Got %lu hosts.", (unsigned long)hosts.size());
39 for (int i = 0; i < nhosts; i++) {
40 LOG2(logp, "Host #%d named \"%s\".", i, hosts[i].get_name());
44 void hostdata::destroy()
46 // hosts are automatically destroyed...
49 hostdata::hostdata(m_host_t host)
50 : name(MSG_host_get_name(host))
51 , ctrl_mbox(std::string(name) + "_ctrl")
52 , data_mbox(std::string(name) + "_data")
54 MSG_host_set_data(host, this);