From: Martin Quinson Date: Tue, 24 Apr 2018 12:35:20 +0000 (+0200) Subject: consistency in host/storage/netpoint registering X-Git-Tag: v3.20~327 X-Git-Url: http://info.iut-bm.univ-fcomte.fr/pub/gitweb/simgrid.git/commitdiff_plain/2212826ed1d2df61b17e5984660e19288247063f consistency in host/storage/netpoint registering --- diff --git a/include/simgrid/s4u/Engine.hpp b/include/simgrid/s4u/Engine.hpp index f71fff5dc6..52f96c5d13 100644 --- a/include/simgrid/s4u/Engine.hpp +++ b/include/simgrid/s4u/Engine.hpp @@ -75,10 +75,14 @@ public: protected: friend s4u::Host; friend s4u::Storage; - void add_host(std::string name, simgrid::s4u::Host* host); - void del_host(std::string name); - void add_storage(std::string name, simgrid::s4u::Storage* storage); - void del_storage(std::string name); + friend kernel::routing::NetPoint; + friend kernel::routing::NetZoneImpl; + void host_register(std::string name, simgrid::s4u::Host* host); + void host_unregister(std::string name); + void storage_register(std::string name, simgrid::s4u::Storage* storage); + void storage_unregister(std::string name); + void netpoint_register(simgrid::kernel::routing::NetPoint* card); + void netpoint_unregister(simgrid::kernel::routing::NetPoint* card); public: size_t get_host_count(); @@ -114,8 +118,6 @@ public: /** @brief Retrieve the netcard of the given name (or nullptr if not found) */ simgrid::kernel::routing::NetPoint* getNetpointByNameOrNull(std::string name); void getNetpointList(std::vector * list); - void netpointRegister(simgrid::kernel::routing::NetPoint * card); - void netpointUnregister(simgrid::kernel::routing::NetPoint * card); /** Returns whether SimGrid was initialized yet -- mostly for internal use */ static bool isInitialized(); diff --git a/src/kernel/routing/NetPoint.cpp b/src/kernel/routing/NetPoint.cpp index 6c38c0cb86..e1b0510aee 100644 --- a/src/kernel/routing/NetPoint.cpp +++ b/src/kernel/routing/NetPoint.cpp @@ -22,7 +22,7 @@ NetPoint::NetPoint(std::string name, NetPoint::Type componentType, NetZoneImpl* id_ = netzone_p->addComponent(this); else id_ = static_cast(-1); - simgrid::s4u::Engine::getInstance()->netpointRegister(this); + simgrid::s4u::Engine::getInstance()->netpoint_register(this); simgrid::kernel::routing::NetPoint::onCreation(this); } } diff --git a/src/kernel/routing/NetZoneImpl.cpp b/src/kernel/routing/NetZoneImpl.cpp index 240309ee9a..94603ef8be 100644 --- a/src/kernel/routing/NetZoneImpl.cpp +++ b/src/kernel/routing/NetZoneImpl.cpp @@ -40,7 +40,7 @@ NetZoneImpl::~NetZoneImpl() for (auto const& kv : bypass_routes_) delete kv.second; - simgrid::s4u::Engine::getInstance()->netpointUnregister(netpoint_); + simgrid::s4u::Engine::getInstance()->netpoint_unregister(netpoint_); } simgrid::s4u::Host* NetZoneImpl::create_host(const char* name, std::vector* speedPerPstate, int coreAmount, diff --git a/src/s4u/s4u_Engine.cpp b/src/s4u/s4u_Engine.cpp index 4f59ca7692..6b174d58f5 100644 --- a/src/s4u/s4u_Engine.cpp +++ b/src/s4u/s4u_Engine.cpp @@ -106,12 +106,12 @@ std::vector Engine::get_all_hosts() return res; } -void Engine::add_host(std::string name, simgrid::s4u::Host* host) +void Engine::host_register(std::string name, simgrid::s4u::Host* host) { pimpl->hosts_[name] = host; } -void Engine::del_host(std::string name) +void Engine::host_unregister(std::string name) { pimpl->hosts_.erase(name); } @@ -153,12 +153,12 @@ simgrid::s4u::Storage* Engine::storage_by_name_or_null(std::string name) return storage == pimpl->storages_.end() ? nullptr : storage->second; } -void Engine::add_storage(std::string name, simgrid::s4u::Storage* storage) +void Engine::storage_register(std::string name, simgrid::s4u::Storage* storage) { pimpl->storages_[name] = storage; } -void Engine::del_storage(std::string name) +void Engine::storage_unregister(std::string name) { pimpl->storages_.erase(name); } @@ -225,14 +225,14 @@ void Engine::getNetpointList(std::vector* l list->push_back(kv.second); } /** @brief Register a new netpoint to the system */ -void Engine::netpointRegister(simgrid::kernel::routing::NetPoint* point) +void Engine::netpoint_register(simgrid::kernel::routing::NetPoint* point) { // simgrid::simix::kernelImmediate([&]{ FIXME: this segfaults in set_thread pimpl->netpoints_[point->get_name()] = point; // }); } /** @brief Unregister a given netpoint */ -void Engine::netpointUnregister(simgrid::kernel::routing::NetPoint* point) +void Engine::netpoint_unregister(simgrid::kernel::routing::NetPoint* point) { simgrid::simix::kernelImmediate([this, point] { pimpl->netpoints_.erase(point->get_name()); diff --git a/src/s4u/s4u_Host.cpp b/src/s4u/s4u_Host.cpp index 7ab0c6f23d..8c448a8811 100644 --- a/src/s4u/s4u_Host.cpp +++ b/src/s4u/s4u_Host.cpp @@ -30,7 +30,7 @@ simgrid::xbt::signal Host::onSpeedChange; Host::Host(const char* name) : name_(name) { xbt_assert(Host::by_name_or_null(name) == nullptr, "Refusing to create a second host named '%s'.", name); - Engine::getInstance()->add_host(std::string(name_), this); + Engine::getInstance()->host_register(std::string(name_), this); new simgrid::surf::HostImpl(this); } @@ -40,7 +40,7 @@ Host::~Host() delete pimpl_; if (pimpl_netpoint != nullptr) // not removed yet by a children class - simgrid::s4u::Engine::getInstance()->netpointUnregister(pimpl_netpoint); + simgrid::s4u::Engine::getInstance()->netpoint_unregister(pimpl_netpoint); delete pimpl_cpu; delete mounts; } @@ -58,7 +58,7 @@ void Host::destroy() if (not currentlyDestroying_) { currentlyDestroying_ = true; onDestruction(*this); - Engine::getInstance()->del_host(std::string(name_)); + Engine::getInstance()->host_unregister(std::string(name_)); delete this; } } diff --git a/src/s4u/s4u_Storage.cpp b/src/s4u/s4u_Storage.cpp index cc6c203c69..a4e08df8fc 100644 --- a/src/s4u/s4u_Storage.cpp +++ b/src/s4u/s4u_Storage.cpp @@ -29,7 +29,7 @@ void XBT_ATTRIB_DEPRECATED_v322( Storage::Storage(std::string name, surf::StorageImpl* pimpl) : pimpl_(pimpl), name_(name) { - simgrid::s4u::Engine::getInstance()->add_storage(name, this); + simgrid::s4u::Engine::getInstance()->storage_register(name, this); } Storage* Storage::byName(std::string name)