Logo AND Algorithmique Numérique Distribuée

Public GIT Repository
Remove xbt_dict host from simix.
authornavarrop <navarrop@48e7efb5-ca39-0410-a469-dd3cf9ba447f>
Thu, 24 Mar 2011 10:35:32 +0000 (10:35 +0000)
committernavarrop <navarrop@48e7efb5-ca39-0410-a469-dd3cf9ba447f>
Thu, 24 Mar 2011 10:35:32 +0000 (10:35 +0000)
git-svn-id: svn+ssh://scm.gforge.inria.fr/svn/simgrid/simgrid/trunk@9829 48e7efb5-ca39-0410-a469-dd3cf9ba447f

include/simix/simix.h
src/msg/environment.c
src/msg/global.c
src/msg/host.c
src/simix/private.h
src/simix/smx_global.c
src/simix/smx_host.c

index 967dd5d..3c810e3 100644 (file)
@@ -51,7 +51,6 @@ XBT_PUBLIC(void) SIMIX_process_set_function(const char* process_host,
                                             double process_kill_time);
 
 /*********************************** Host *************************************/
                                             double process_kill_time);
 
 /*********************************** Host *************************************/
-XBT_PUBLIC(xbt_dict_t) SIMIX_host_get_dict(void);
 XBT_PUBLIC(smx_host_t) SIMIX_host_get_by_name(const char *name);
 XBT_PUBLIC(smx_host_t) SIMIX_host_self(void);
 XBT_PUBLIC(const char*) SIMIX_host_self_get_name(void);
 XBT_PUBLIC(smx_host_t) SIMIX_host_get_by_name(const char *name);
 XBT_PUBLIC(smx_host_t) SIMIX_host_self(void);
 XBT_PUBLIC(const char*) SIMIX_host_self_get_name(void);
index 633995f..fca4a9f 100644 (file)
@@ -62,15 +62,16 @@ m_host_t MSG_get_host_by_name(const char *name)
  */
 void MSG_create_environment(const char *file)
 {
  */
 void MSG_create_environment(const char *file)
 {
-  xbt_dict_cursor_t c;
-  smx_host_t h;
+  xbt_lib_cursor_t cursor;
+  void **data;
   char *name;
 
   SIMIX_create_environment(file);
 
   /* Initialize MSG hosts */
   char *name;
 
   SIMIX_create_environment(file);
 
   /* Initialize MSG hosts */
-  xbt_dict_foreach(SIMIX_host_get_dict(), c, name, h) {
-    __MSG_host_create(h, NULL);
+  xbt_lib_foreach(host_lib, cursor, name, data) {
+       if(data[SIMIX_HOST_LEVEL])
+      __MSG_host_create((smx_host_t)data[SIMIX_HOST_LEVEL], NULL);
   }
   return;
 }
   }
   return;
 }
index c7f7d2e..7df2150 100644 (file)
@@ -64,7 +64,6 @@ void MSG_global_init(int *argc, char **argv)
 
     msg_global = xbt_new0(s_MSG_Global_t, 1);
 
 
     msg_global = xbt_new0(s_MSG_Global_t, 1);
 
-    msg_global->host = xbt_fifo_new();
     msg_global->max_channel = 0;
     msg_global->PID = 1;
     msg_global->sent_msg = 0;
     msg_global->max_channel = 0;
     msg_global->PID = 1;
     msg_global->sent_msg = 0;
@@ -179,8 +178,6 @@ int MSG_process_killall(int reset_PIDs)
  */
 MSG_error_t MSG_clean(void)
 {
  */
 MSG_error_t MSG_clean(void)
 {
-  xbt_fifo_item_t i = NULL;
-  m_host_t h = NULL;
 
 #ifdef HAVE_TRACING
   TRACE_surf_release();
 
 #ifdef HAVE_TRACING
   TRACE_surf_release();
@@ -188,11 +185,6 @@ MSG_error_t MSG_clean(void)
 
   MSG_process_killall(0);
 
 
   MSG_process_killall(0);
 
-  xbt_fifo_foreach(msg_global->host, i, h, m_host_t) {
-    __MSG_host_destroy(h);
-  }
-  xbt_fifo_free(msg_global->host);
-
   free(msg_global);
   msg_global = NULL;
 
   free(msg_global);
   msg_global = NULL;
 
index 20541bc..62ca0d8 100644 (file)
@@ -55,9 +55,7 @@ m_host_t __MSG_host_create(smx_host_t workstation, void *data)
   }
 
   SIMIX_req_host_set_data(workstation, host);
   }
 
   SIMIX_req_host_set_data(workstation, host);
-
-  /* Update global variables */
-  xbt_fifo_unshift(msg_global->host, host);
+  xbt_lib_set(host_lib,name,MSG_HOST_LEVEL,host);
 
   return host;
 }
 
   return host;
 }
@@ -125,7 +123,6 @@ m_host_t MSG_host_self(void)
 /*
  * Real function to destroy a host.
  * MSG_host_destroy is just  a front_end that also removes it from 
 /*
  * Real function to destroy a host.
  * MSG_host_destroy is just  a front_end that also removes it from 
- * msg_global->host
  */
 void __MSG_host_destroy(m_host_t host)
 {
  */
 void __MSG_host_destroy(m_host_t host)
 {
@@ -153,8 +150,6 @@ void __MSG_host_destroy(m_host_t host)
   /* Clean host structure */
   free(host->name);
   free(host);
   /* Clean host structure */
   free(host->name);
   free(host);
-
-
 }
 
 /** \ingroup m_host_management
 }
 
 /** \ingroup m_host_management
@@ -162,7 +157,7 @@ void __MSG_host_destroy(m_host_t host)
  */
 int MSG_get_host_number(void)
 {
  */
 int MSG_get_host_number(void)
 {
-  return (xbt_fifo_size(msg_global->host));
+  return host_lib->count;
 }
 
 /** \ingroup m_host_management
 }
 
 /** \ingroup m_host_management
@@ -170,7 +165,23 @@ int MSG_get_host_number(void)
  */
 m_host_t *MSG_get_host_table(void)
 {
  */
 m_host_t *MSG_get_host_table(void)
 {
-  return ((m_host_t *) xbt_fifo_to_array(msg_global->host));
+      void **array;
+         int i = 0;
+         xbt_lib_cursor_t cursor;
+         char *key;
+         void **data;
+
+         if (host_lib->count == 0)
+               return NULL;
+         else
+               array = xbt_new0(void *, host_lib->count);
+
+         xbt_lib_foreach(host_lib, cursor, key, data) {
+           if(get_network_element_type(key) == SURF_NETWORK_ELEMENT_HOST)
+               array[i++] = data[MSG_HOST_LEVEL];
+         }
+
+         return (m_host_t *)array;
 }
 
 /** \ingroup m_host_management
 }
 
 /** \ingroup m_host_management
index 676d923..ac56516 100644 (file)
@@ -30,7 +30,6 @@
 /********************************** Simix Global ******************************/
 typedef struct s_smx_global {
   smx_context_factory_t context_factory;
 /********************************** Simix Global ******************************/
 typedef struct s_smx_global {
   smx_context_factory_t context_factory;
-  xbt_dict_t host;
   xbt_dynar_t process_to_run;
   xbt_swag_t process_list;
   xbt_swag_t process_to_destroy;
   xbt_dynar_t process_to_run;
   xbt_swag_t process_list;
   xbt_swag_t process_to_destroy;
index a486e41..f3da01e 100644 (file)
@@ -72,7 +72,6 @@ void SIMIX_global_init(int *argc, char **argv)
 
     simix_global = xbt_new0(s_smx_global_t, 1);
 
 
     simix_global = xbt_new0(s_smx_global_t, 1);
 
-    simix_global->host = xbt_dict_new();
     simix_global->process_to_run = xbt_dynar_new(sizeof(void *), NULL);
     simix_global->process_list =
         xbt_swag_new(xbt_swag_offset(proc, process_hookup));
     simix_global->process_to_run = xbt_dynar_new(sizeof(void *), NULL);
     simix_global->process_list =
         xbt_swag_new(xbt_swag_offset(proc, process_hookup));
@@ -142,7 +141,6 @@ void SIMIX_clean(void)
   simix_global->process_list = NULL;
   simix_global->process_to_destroy = NULL;
   xbt_dict_free(&(simix_global->registered_functions));
   simix_global->process_list = NULL;
   simix_global->process_to_destroy = NULL;
   xbt_dict_free(&(simix_global->registered_functions));
-  xbt_dict_free(&(simix_global->host));
 
   /* Let's free maestro now */
   SIMIX_context_free(simix_global->maestro_process->context);
 
   /* Let's free maestro now */
   SIMIX_context_free(simix_global->maestro_process->context);
index b6eaec1..b655087 100644 (file)
@@ -36,8 +36,7 @@ smx_host_t SIMIX_host_create(const char *name,
       xbt_swag_new(xbt_swag_offset(proc, host_proc_hookup));
 
   /* Update global variables */
       xbt_swag_new(xbt_swag_offset(proc, host_proc_hookup));
 
   /* Update global variables */
-  xbt_dict_set(simix_global->host, smx_host->name, smx_host,
-               &SIMIX_host_destroy);
+  xbt_lib_set(host_lib,smx_host->name,SIMIX_HOST_LEVEL,smx_host);
 
   return smx_host;
 }
 
   return smx_host;
 }
@@ -78,23 +77,13 @@ void SIMIX_host_destroy(void *h)
   return;
 }
 
   return;
 }
 
-/**
- * \brief Returns a dict of all hosts.
- *
- * \return List of all hosts (as a #xbt_dict_t)
- */
-xbt_dict_t SIMIX_host_get_dict(void)
-{
-  return simix_global->host;
-}
-
 smx_host_t SIMIX_host_get_by_name(const char *name)
 {
   xbt_assert0(((simix_global != NULL)
 smx_host_t SIMIX_host_get_by_name(const char *name)
 {
   xbt_assert0(((simix_global != NULL)
-               && (simix_global->host != NULL)),
+               && (host_lib != NULL)),
               "Environment not set yet");
 
               "Environment not set yet");
 
-  return xbt_dict_get_or_null(simix_global->host, name);
+  return xbt_lib_get_or_null(host_lib, name, SIMIX_HOST_LEVEL);
 }
 
 smx_host_t SIMIX_host_self(void)
 }
 
 smx_host_t SIMIX_host_self(void)