From: Martin Quinson Date: Sun, 16 Oct 2016 14:54:47 +0000 (+0200) Subject: code simplifications around host construction X-Git-Tag: v3_14~316 X-Git-Url: http://info.iut-bm.univ-fcomte.fr/pub/gitweb/simgrid.git/commitdiff_plain/35b35e718112334559d3eca351170c79077d9335?ds=sidebyside code simplifications around host construction Storage list is passed as a parameter, not through a global dict of storages. --- diff --git a/src/surf/HostImpl.cpp b/src/surf/HostImpl.cpp index 1185becf37..c425691ce9 100644 --- a/src/surf/HostImpl.cpp +++ b/src/surf/HostImpl.cpp @@ -29,10 +29,11 @@ simgrid::xbt::Extension HostImpl::EXTENSION_ID; /********* * Model * *********/ -HostImpl *HostModel::createHost(const char *name, kernel::routing::NetCard *netElm, Cpu *cpu){ - xbt_dynar_t storageList = (xbt_dynar_t)xbt_lib_get_or_null(storage_lib, name, ROUTING_STORAGE_HOST_LEVEL); - +HostImpl* HostModel::createHost(const char* name, Cpu* cpu, kernel::routing::NetCard* netcard, xbt_dynar_t storageList) +{ HostImpl *host = new simgrid::surf::HostImpl(surf_host_model, name, storageList, cpu); + xbt_lib_set(storage_lib, name, ROUTING_STORAGE_HOST_LEVEL, (void*)storageList); + XBT_DEBUG("Create host %s with %ld mounted disks", name, xbt_dynar_length(host->storage_)); return host; } diff --git a/src/surf/HostImpl.hpp b/src/surf/HostImpl.hpp index 32d94178df..a032f6c407 100644 --- a/src/surf/HostImpl.hpp +++ b/src/surf/HostImpl.hpp @@ -51,7 +51,7 @@ class HostModel : public Model { public: HostModel() : Model() {} - HostImpl *createHost(const char *name, kernel::routing::NetCard *net, Cpu *cpu); + HostImpl* createHost(const char* name, Cpu* cpu, kernel::routing::NetCard* net, xbt_dynar_t storageList); virtual void adjustWeightOfDummyCpuActions(); virtual Action *executeParallelTask(int host_nb, sg_host_t *host_list, diff --git a/src/surf/sg_platf.cpp b/src/surf/sg_platf.cpp index 59997d93a6..1d9ddd038f 100644 --- a/src/surf/sg_platf.cpp +++ b/src/surf/sg_platf.cpp @@ -72,7 +72,7 @@ void sg_platf_exit() { surf_parse_lex_destroy(); } -/** @brief Add an "host" to the current AS */ +/** @brief Add an host to the current AS */ void sg_platf_new_host(sg_platf_host_cbarg_t host) { simgrid::kernel::routing::AsImpl* current_routing = routing_get_current(); @@ -85,11 +85,6 @@ void sg_platf_new_host(sg_platf_host_cbarg_t host) simgrid::s4u::Host* h = new simgrid::s4u::Host(host->id); h->pimpl_netcard = netcard; - if(mount_list) { - xbt_lib_set(storage_lib, host->id, ROUTING_STORAGE_HOST_LEVEL, (void *) mount_list); - mount_list = nullptr; - } - if (host->coord && strcmp(host->coord, "")) { unsigned int cursor; char*str; @@ -114,7 +109,9 @@ void sg_platf_new_host(sg_platf_host_cbarg_t host) cpu->setStateTrace(host->state_trace); if (host->speed_trace) cpu->setSpeedTrace(host->speed_trace); - surf_host_model->createHost(host->id, netcard, cpu)->attach(h); + + surf_host_model->createHost(host->id, cpu, netcard, mount_list)->attach(h); + mount_list = nullptr; if (host->properties) { xbt_dict_cursor_t cursor=nullptr;