Logo AND Algorithmique Numérique Distribuée

Public GIT Repository
create a NetZone::onCreation signal and use it from instr
authorMartin Quinson <martin.quinson@loria.fr>
Wed, 7 Jun 2017 15:30:36 +0000 (17:30 +0200)
committerMartin Quinson <martin.quinson@loria.fr>
Wed, 7 Jun 2017 15:30:36 +0000 (17:30 +0200)
include/simgrid/s4u/NetZone.hpp
src/kernel/routing/NetZoneImpl.cpp
src/s4u/s4u_netzone.cpp
src/surf/instr_routing.cpp
src/surf/sg_platf.cpp
src/surf/xml/platf_private.hpp

index b0accf1..4dc88c3 100644 (file)
@@ -67,6 +67,7 @@ public:
                                    kernel::routing::NetPoint* gw_src, kernel::routing::NetPoint* gw_dst,
                                    std::vector<surf::LinkImpl*>* link_list)>
       onRouteCreation;
+  static simgrid::xbt::signal<void(NetZone&)> onCreation;
 
 protected:
   std::vector<kernel::routing::NetPoint*>
index dc21bff..dc90792 100644 (file)
@@ -58,7 +58,7 @@ simgrid::s4u::Host* NetZoneImpl::createHost(const char* name, std::vector<double
     for (auto kv : *props)
       res->setProperty(kv.first.c_str(), kv.second.c_str());
 
-  simgrid::s4u::Host::onCreation(*res);
+  simgrid::s4u::Host::onCreation(*res); // notify the signal
 
   return res;
 }
index f539136..3886322 100644 (file)
@@ -20,6 +20,7 @@ simgrid::xbt::signal<void(bool symmetrical, kernel::routing::NetPoint* src, kern
                           kernel::routing::NetPoint* gw_src, kernel::routing::NetPoint* gw_dst,
                           std::vector<surf::LinkImpl*>* link_list)>
     NetZone::onRouteCreation;
+simgrid::xbt::signal<void(NetZone&)> NetZone::onCreation;
 
 NetZone::NetZone(NetZone* father, const char* name) : father_(father), name_(xbt_strdup(name))
 {
index 2baf7b9..4f4902a 100644 (file)
@@ -162,9 +162,9 @@ static void recursiveGraphExtraction(simgrid::s4u::NetZone* netzone, container_t
 /*
  * Callbacks
  */
-void sg_instr_AS_begin(sg_platf_AS_cbarg_t AS)
+static void sg_instr_AS_begin(simgrid::s4u::NetZone& netzone)
 {
-  const char*id = AS->id;
+  const char* id = netzone.name();
 
   if (PJ_container_get_root() == nullptr){
     PJ_container_alloc ();
@@ -318,11 +318,14 @@ void instr_routing_define_callbacks ()
 {
   //always need the call backs to ASes (we need only the root AS),
   //to create the rootContainer and the rootType properly
-  if (not TRACE_is_enabled() || not TRACE_needs_platform())
+  if (not TRACE_is_enabled())
     return;
-  simgrid::s4u::Link::onCreation.connect(instr_routing_parse_start_link);
-  simgrid::s4u::onPlatformCreated.connect(instr_routing_parse_end_platform);
-  simgrid::s4u::Host::onCreation.connect(sg_instr_new_host);
+  if (TRACE_needs_platform()) {
+    simgrid::s4u::Link::onCreation.connect(instr_routing_parse_start_link);
+    simgrid::s4u::onPlatformCreated.connect(instr_routing_parse_end_platform);
+    simgrid::s4u::Host::onCreation.connect(sg_instr_new_host);
+  }
+  simgrid::s4u::NetZone::onCreation.connect(sg_instr_AS_begin);
 }
 
 /*
index 2e10ec0..7eb25fc 100644 (file)
@@ -662,8 +662,7 @@ simgrid::s4u::NetZone* sg_platf_new_AS_begin(sg_platf_AS_cbarg_t AS)
   /* set the new current component of the tree */
   current_routing = new_as;
 
-  if (TRACE_is_enabled())
-    sg_instr_AS_begin(AS);
+  simgrid::s4u::NetZone::onCreation(*new_as); // notify the signal
 
   return new_as;
 }
index 2bc61f3..9b353f6 100644 (file)
@@ -245,7 +245,6 @@ XBT_PUBLIC_DATA(int) surfxml_bufferstack_size;
 
 XBT_PUBLIC(void) routing_route_free(sg_platf_route_cbarg_t route);
 /********** Instr. **********/
-XBT_PRIVATE void sg_instr_AS_begin(sg_platf_AS_cbarg_t AS);
 XBT_PRIVATE void sg_instr_new_router(const char* name);
 XBT_PRIVATE void sg_instr_AS_end();