Logo AND Algorithmique Numérique Distribuée

Public GIT Repository
Revert "remove a C-like pimple"
authorGabriel Corona <gabriel.corona@loria.fr>
Tue, 12 Jan 2016 11:24:12 +0000 (12:24 +0100)
committerGabriel Corona <gabriel.corona@loria.fr>
Tue, 12 Jan 2016 12:10:38 +0000 (13:10 +0100)
This reverts commit 71c619779ed661b50ce589403a0f4df7ab0865de.

This commits generates a lot of segfaults.

src/surf/host_interface.cpp
src/surf/host_interface.hpp
src/surf/surf_interface.cpp

index bc4e286..a4367e1 100644 (file)
@@ -31,10 +31,7 @@ void host_add_traces(){
 namespace simgrid {
 namespace surf {
 
 namespace simgrid {
 namespace surf {
 
-simgrid::xbt::Extension<simgrid::Host, Host> Host::EXTENSION_ID =
-               simgrid::Host::extension_create<simgrid::surf::Host>([](void *h) {
-               static_cast<simgrid::surf::Host*>(h)->destroy();
-        });
+simgrid::xbt::Extension<simgrid::Host, Host> Host::EXTENSION_ID;
 
 /*********
  * Model *
 
 /*********
  * Model *
@@ -89,6 +86,15 @@ simgrid::surf::signal<void(simgrid::surf::Host*)> Host::onCreation;
 simgrid::surf::signal<void(simgrid::surf::Host*)> Host::onDestruction;
 simgrid::surf::signal<void(simgrid::surf::Host*)> Host::onStateChange;
 
 simgrid::surf::signal<void(simgrid::surf::Host*)> Host::onDestruction;
 simgrid::surf::signal<void(simgrid::surf::Host*)> Host::onStateChange;
 
+void Host::classInit()
+{
+  if (!EXTENSION_ID.valid()) {
+    EXTENSION_ID = simgrid::Host::extension_create<simgrid::surf::Host>([](void *h) {
+       static_cast<simgrid::surf::Host*>(h)->destroy();
+    });
+  }
+}
+
 Host::Host(simgrid::surf::Model *model, const char *name, xbt_dict_t props,
                                 xbt_dynar_t storage, Cpu *cpu)
  : Resource(model, name)
 Host::Host(simgrid::surf::Model *model, const char *name, xbt_dict_t props,
                                 xbt_dynar_t storage, Cpu *cpu)
  : Resource(model, name)
index a907656..236ccdb 100644 (file)
@@ -84,6 +84,7 @@ public:
   static simgrid::surf::signal<void(Host*)> onStateChange; /** Called when the machine is turned on or off */
 
 public:
   static simgrid::surf::signal<void(Host*)> onStateChange; /** Called when the machine is turned on or off */
 
 public:
+  static void classInit(); // must be called before the first use of that class
   /**
    * @brief Host constructor
    *
   /**
    * @brief Host constructor
    *
index a69aac5..b8d0eaf 100644 (file)
@@ -318,6 +318,7 @@ void surf_init(int *argc, char **argv)
   ROUTING_PROP_ASR_LEVEL = xbt_lib_add_level(as_router_lib,routing_asr_prop_free);
 
   XBT_DEBUG("Add SURF levels");
   ROUTING_PROP_ASR_LEVEL = xbt_lib_add_level(as_router_lib,routing_asr_prop_free);
 
   XBT_DEBUG("Add SURF levels");
+  simgrid::surf::Host::classInit();
   SURF_STORAGE_LEVEL = xbt_lib_add_level(storage_lib,surf_storage_free);
 
   xbt_init(argc, argv);
   SURF_STORAGE_LEVEL = xbt_lib_add_level(storage_lib,surf_storage_free);
 
   xbt_init(argc, argv);