X-Git-Url: http://info.iut-bm.univ-fcomte.fr/pub/gitweb/simgrid.git/blobdiff_plain/0bac7d0f735ac8ba47a46e1db4f6d7a7164fe0f2..b197602d9f391f0020949e793fd191bb722af74a:/src/simgrid/host.cpp diff --git a/src/simgrid/host.cpp b/src/simgrid/host.cpp index 376392a9c9..c4c9f2042b 100644 --- a/src/simgrid/host.cpp +++ b/src/simgrid/host.cpp @@ -31,12 +31,12 @@ size_t sg_host_add_level(void(*deleter)(void*)) sg_host_t sg_host_by_name(const char *name) { - return simgrid::Host::find_host(name); + return simgrid::Host::by_name_or_null(name); } sg_host_t sg_host_by_name_or_create(const char *name) { - return simgrid::Host::get_host(name); + return simgrid::Host::by_name_or_create(name); } xbt_dynar_t sg_hosts_as_dynar(void) @@ -58,7 +58,6 @@ int MSG_HOST_LEVEL; int SD_HOST_LEVEL; int SIMIX_HOST_LEVEL; int ROUTING_HOST_LEVEL; -int SURF_CPU_LEVEL; int USER_HOST_LEVEL; #include "src/msg/msg_private.h" // MSG_host_priv_free. FIXME: killme @@ -81,7 +80,7 @@ void sg_host_init() }); SD_HOST_LEVEL = simgrid::Host::add_level(__SD_workstation_destroy); SIMIX_HOST_LEVEL = simgrid::Host::add_level(SIMIX_host_destroy); - SURF_CPU_LEVEL = simgrid::Host::add_level(surf_cpu_free); + simgrid::surf::Cpu::init(); ROUTING_HOST_LEVEL = simgrid::Host::add_level(routing_asr_host_free); USER_HOST_LEVEL = simgrid::Host::add_level(NULL); } @@ -131,19 +130,13 @@ void sg_host_simix_destroy(sg_host_t host) { // ========== SURF CPU ============ surf_cpu_t sg_host_surfcpu(sg_host_t host) { - return (surf_cpu_t) host->facet(SURF_CPU_LEVEL); + return host->facet(); } void sg_host_surfcpu_set(sg_host_t host, surf_cpu_t cpu) { - host->set_facet(SURF_CPU_LEVEL, cpu); -} -void sg_host_surfcpu_register(sg_host_t host, surf_cpu_t cpu) -{ - surf_callback_emit(simgrid::surf::cpuCreatedCallbacks, cpu); - surf_callback_emit(simgrid::surf::cpuStateChangedCallbacks, cpu, SURF_RESOURCE_ON, cpu->getState()); - sg_host_surfcpu_set(host, cpu); + host->set_facet(simgrid::surf::Cpu::LEVEL, cpu); } void sg_host_surfcpu_destroy(sg_host_t host) { - host->set_facet(SURF_CPU_LEVEL, nullptr); + host->set_facet(nullptr); } // ========== RoutingEdge ============ surf_RoutingEdge *sg_host_edge(sg_host_t host) { @@ -202,8 +195,8 @@ int sg_host_get_pstate(sg_host_t host) { namespace simgrid { -Host::Host(std::string id) - : id_(std::move(id)) +Host::Host(std::string const& id) + : id_(id) { } @@ -211,14 +204,14 @@ Host::~Host() { } -Host* Host::find_host(const char* name) +Host* Host::by_name_or_null(const char* name) { return (Host*) xbt_dict_get_or_null(host_list, name); } -Host* Host::get_host(const char* name) +Host* Host::by_name_or_create(const char* name) { - Host* host = find_host(name); + Host* host = by_name_or_null(name); if (host == nullptr) { host = new Host(name); xbt_dict_set(host_list, name, host, NULL);