Logo AND Algorithmique Numérique Distribuée

Public GIT Repository
[trace] functions to be used by other parts of tracing (container handling)
authorschnorr <schnorr@48e7efb5-ca39-0410-a469-dd3cf9ba447f>
Mon, 13 Dec 2010 16:45:13 +0000 (16:45 +0000)
committerschnorr <schnorr@48e7efb5-ca39-0410-a469-dd3cf9ba447f>
Mon, 13 Dec 2010 16:45:13 +0000 (16:45 +0000)
git-svn-id: svn+ssh://scm.gforge.inria.fr/svn/simgrid/simgrid/trunk@9202 48e7efb5-ca39-0410-a469-dd3cf9ba447f

src/instr/instr_private.h
src/instr/instr_routing.c

index e71d88d..55e647c 100644 (file)
@@ -216,6 +216,9 @@ void TRACE_sd_task_create(SD_task_t task);
 void TRACE_sd_task_destroy(SD_task_t task);
 
 /* instr_routing.c */
+container_t newContainer (const char *name, e_container_types kind, container_t father);
+container_t getContainer (const char *name);
+void destroyContainer (container_t container);
 void instr_routing_define_callbacks (void);
 int instr_link_is_traced (const char *name);
 char *instr_variable_type (const char *name, const char *resource);
index b053a89..b866969 100644 (file)
@@ -157,7 +157,7 @@ static long long int newContainedId ()
   return counter++;
 }
 
-static container_t newContainer (const char *name, e_container_types kind, container_t father)
+container_t newContainer (const char *name, e_container_types kind, container_t father)
 {
   long long int counter = newContainedId();
   char id_str[INSTR_DEFAULT_STR_SIZE];
@@ -217,6 +217,43 @@ static container_t newContainer (const char *name, e_container_types kind, conta
   return new;
 }
 
+static container_t recursiveGetContainer (const char *name, container_t root)
+{
+  if (strcmp (root->name, name) == 0) return root;
+
+  xbt_dict_cursor_t cursor = NULL;
+  container_t child;
+  char *child_name;
+  xbt_dict_foreach(root->children, cursor, child_name, child) {
+    container_t ret = recursiveGetContainer(name, child);
+    if (ret) return ret;
+  }
+  return NULL;
+}
+
+container_t getContainer (const char *name)
+{
+  return recursiveGetContainer(name, rootContainer);
+}
+
+void destroyContainer (container_t container)
+{
+  //remove me from my father
+  if (container->father){
+    xbt_dict_remove(container->father->children, container->name);
+  }
+
+  //trace my destruction
+  pajeDestroyContainer(SIMIX_get_clock(), container->type->id, container->id);
+
+  //free
+  xbt_free (container->name);
+  xbt_free (container->id);
+  xbt_free (container->children);
+  xbt_free (container);
+  container = NULL;
+}
+
 static container_t findChild (container_t root, container_t a1)
 {
   if (root == a1) return root;
@@ -492,14 +529,7 @@ static void recursiveDestroyContainer (container_t container)
   xbt_dict_foreach(container->children, cursor, child_name, child) {
     recursiveDestroyContainer (child);
   }
-
-  pajeDestroyContainer(SIMIX_get_clock(), container->type->id, container->id);
-
-  xbt_free (container->name);
-  xbt_free (container->id);
-  xbt_free (container->children);
-  xbt_free (container);
-  container = NULL;
+  destroyContainer (container);
 }
 
 static void recursiveDestroyType (type_t type)