Logo AND Algorithmique Numérique Distribuée

Public GIT Repository
don't hide the C++, deal with it
authorMartin Quinson <martin.quinson@loria.fr>
Wed, 15 Feb 2017 23:15:10 +0000 (00:15 +0100)
committerMartin Quinson <martin.quinson@loria.fr>
Wed, 15 Feb 2017 23:40:55 +0000 (00:40 +0100)
include/simgrid/host.h
src/simgrid/host.cpp
src/simix/ActorImpl.cpp
src/simix/smx_host.cpp
src/surf/sg_platf.cpp

index 0808f66..eac85bf 100644 (file)
@@ -32,9 +32,6 @@ XBT_PUBLIC(void*) sg_host_user(sg_host_t host);
 XBT_PUBLIC(void) sg_host_user_set(sg_host_t host, void* userdata);
 XBT_PUBLIC(void) sg_host_user_destroy(sg_host_t host);
 
-// ========== Simix layer =============
-XBT_PUBLIC(smx_host_priv_t) sg_host_simix(sg_host_t host);
-
 // ========= storage related functions ============
 XBT_PUBLIC(xbt_dict_t) sg_host_get_mounted_storage_list(sg_host_t host);
 XBT_PUBLIC(xbt_dynar_t) sg_host_get_attached_storage_list(sg_host_t host);
index 977068c..2a364a7 100644 (file)
@@ -116,11 +116,6 @@ void sg_host_user_destroy(sg_host_t host) {
   host->extension_set(USER_HOST_LEVEL, nullptr);
 }
 
-// ========== Simix layer =============
-smx_host_priv_t sg_host_simix(sg_host_t host){
-  return host->extension<simgrid::simix::Host>();
-}
-
 // ========= storage related functions ============
 xbt_dict_t sg_host_get_mounted_storage_list(sg_host_t host){
   return host->pimpl_->getMountedStorageList();
index 469386d..7ae8a53 100644 (file)
@@ -135,7 +135,7 @@ void SIMIX_process_cleanup(smx_actor_t process)
   XBT_DEBUG("%p should not be run anymore",process);
   simix_global->process_list.erase(process->pid);
   if (process->host)
-    xbt_swag_remove(process, sg_host_simix(process->host)->process_list);
+    xbt_swag_remove(process, process->host->extension<simgrid::simix::Host>()->process_list);
   xbt_swag_insert(process, simix_global->process_to_destroy);
   process->context->iwannadie = 0;
 
@@ -274,7 +274,7 @@ smx_actor_t SIMIX_process_create(
     process->properties = properties;
 
     /* Add the process to it's host process list */
-    xbt_swag_insert(process, sg_host_simix(host)->process_list);
+    xbt_swag_insert(process, host->extension<simgrid::simix::Host>()->process_list);
 
     XBT_DEBUG("Start context '%s'", process->name.c_str());
 
@@ -354,7 +354,7 @@ smx_actor_t SIMIX_process_attach(
   process->properties = properties;
 
   /* Add the process to it's host process list */
-  xbt_swag_insert(process, sg_host_simix(host)->process_list);
+  xbt_swag_insert(process, host->extension<simgrid::simix::Host>()->process_list);
 
   /* Now insert it in the global process list and in the process to run list */
   simix_global->process_list[process->pid] = process;
@@ -559,9 +559,9 @@ void simcall_HANDLER_process_set_host(smx_simcall_t simcall, smx_actor_t process
 void SIMIX_process_change_host(smx_actor_t process, sg_host_t dest)
 {
   xbt_assert((process != nullptr), "Invalid parameters");
-  xbt_swag_remove(process, sg_host_simix(process->host)->process_list);
+  xbt_swag_remove(process, process->host->extension<simgrid::simix::Host>()->process_list);
   process->host = dest;
-  xbt_swag_insert(process, sg_host_simix(dest)->process_list);
+  xbt_swag_insert(process, dest->extension<simgrid::simix::Host>()->process_list);
 }
 
 
index dab3c22..1e5791c 100644 (file)
@@ -75,7 +75,7 @@ namespace simgrid {
 /** @brief Stop the host if it is on */
 void SIMIX_host_off(sg_host_t h, smx_actor_t issuer)
 {
-  smx_host_priv_t host = sg_host_simix(h);
+  smx_host_priv_t host = h->extension<simgrid::simix::Host>();
 
   xbt_assert((host != nullptr), "Invalid parameters");
 
@@ -140,17 +140,15 @@ void SIMIX_host_add_auto_restart_process(
     xbt_dict_set(watched_hosts_lib, host->cname(), host, nullptr);
     XBT_DEBUG("Push host %s to watched_hosts_lib because state == SURF_RESOURCE_OFF", host->cname());
   }
-  sg_host_simix(host)->auto_restart_processes.push_back(arg);
+  host->extension<simgrid::simix::Host>()->auto_restart_processes.push_back(arg);
 }
 /** @brief Restart the list of processes that have been registered to the host */
 void SIMIX_host_autorestart(sg_host_t host)
 {
-  std::vector<simgrid::simix::ProcessArg*> process_list = sg_host_simix(host)->auto_restart_processes;
-  if (process_list.empty())
-    return;
+  std::vector<simgrid::simix::ProcessArg*> process_list =
+      host->extension<simgrid::simix::Host>()->auto_restart_processes;
 
   for (auto arg : process_list) {
-
     XBT_DEBUG("Restarting Process %s@%s right now", arg->name.c_str(), arg->host->cname());
     simix_global->create_process_function(arg->name.c_str(), arg->code, nullptr, arg->host, arg->kill_time,
         arg->properties, arg->auto_restart, nullptr);
index ac3ce92..7b0efe7 100644 (file)
@@ -507,7 +507,7 @@ void sg_platf_new_process(sg_platf_process_cbarg_t process)
   arg->kill_time = kill_time;
   arg->properties = current_property_set;
 
-  sg_host_simix(host)->boot_processes.push_back(arg);
+  host->extension<simgrid::simix::Host>()->boot_processes.push_back(arg);
 
   if (start_time > SIMIX_get_clock()) {