Logo AND Algorithmique Numérique Distribuée

Public GIT Repository
[surf] Move the hostCreatedCallbacks after the constructor
authorGabriel Corona <gabriel.corona@loria.fr>
Tue, 24 Nov 2015 10:06:04 +0000 (11:06 +0100)
committerGabriel Corona <gabriel.corona@loria.fr>
Tue, 24 Nov 2015 11:54:39 +0000 (12:54 +0100)
The callbacks were called in the Host constructor which is at the very
beginning og the object construction: the fields of the derived
classes are not initialized at this point and the correct virtual
methods are not available.

src/surf/host_clm03.cpp
src/surf/host_interface.cpp
src/surf/host_ptask_L07.cpp

index 19b53bc..227855f 100644 (file)
@@ -50,6 +50,7 @@ Host *HostCLM03Model::createHost(const char *name){
                  (xbt_dynar_t)xbt_lib_get_or_null(storage_lib, name, ROUTING_STORAGE_HOST_LEVEL),
                  sg_host_edge(sg_host),
                  sg_host_surfcpu(sg_host));
+  surf_callback_emit(hostCreatedCallbacks, host);
   XBT_DEBUG("Create host %s with %ld mounted disks", name, xbt_dynar_length(host->p_storage));
   xbt_lib_set(host_lib, name, SURF_HOST_LEVEL, host);
   return host;
index 025df7c..3c79032 100644 (file)
@@ -83,7 +83,6 @@ Host::Host(Model *model, const char *name, xbt_dict_t props,
  , p_storage(storage), p_netElm(netElm), p_cpu(cpu)
 {
   p_params.ramsize = 0;
-  surf_callback_emit(hostCreatedCallbacks, this);
 }
 
 Host::Host(Model *model, const char *name, xbt_dict_t props, lmm_constraint_t constraint,
@@ -92,7 +91,6 @@ Host::Host(Model *model, const char *name, xbt_dict_t props, lmm_constraint_t co
  , p_storage(storage), p_netElm(netElm), p_cpu(cpu)
 {
   p_params.ramsize = 0;
-  surf_callback_emit(hostCreatedCallbacks, this);
 }
 
 Host::~Host(){
index 0c5645a..2114c97 100644 (file)
@@ -277,7 +277,7 @@ Host *HostL07Model::createHost(const char *name)
   wk = new HostL07(this, name, NULL,
                                  sg_host_edge(sg_host),
                                                  sg_host_surfcpu(sg_host));
-
+  surf_callback_emit(hostCreatedCallbacks, wk);
   xbt_lib_set(host_lib, name, SURF_HOST_LEVEL, wk);
 
   return wk;