Logo AND Algorithmique Numérique Distribuée

Public GIT Repository
cosmetics: rename a function, deprecate old name
[simgrid.git] / src / surf / plugins / link_energy.cpp
index b81cd6fe9eeed76deda5f373521724fe2731e1ba..d4a9f3780c6aeef05859fb91e8255802607cfd43 100644 (file)
@@ -164,8 +164,7 @@ static void onCommunicate(simgrid::surf::NetworkAction* action, simgrid::s4u::Ho
 
 static void onSimulationEnd()
 {
-  std::vector<simgrid::s4u::Link*> links;
-  simgrid::s4u::Engine::getInstance()->getLinkList(&links);
+  std::vector<simgrid::s4u::Link*> links = simgrid::s4u::Engine::getInstance()->getAllLinks();
 
   double total_energy = 0.0; // Total dissipated energy (whole platform)
   for (const auto link : links) {
@@ -193,6 +192,8 @@ void sg_link_energy_plugin_init()
     return;
   LinkEnergy::EXTENSION_ID = simgrid::s4u::Link::extension_create<LinkEnergy>();
 
+  xbt_assert(sg_host_count() == 0, "Please call sg_link_energy_plugin_init() before initializing the platform.");
+
   simgrid::s4u::Link::onCreation.connect([](simgrid::s4u::Link& link) {
     link.extension_set(new LinkEnergy(&link));
   });