Logo AND Algorithmique Numérique Distribuée

Public GIT Repository
kill two useless functions at once
[simgrid.git] / src / simix / smx_host.cpp
index 6f932c5..f27e7ac 100644 (file)
 
 XBT_LOG_NEW_DEFAULT_SUBCATEGORY(simix_host, simix, "SIMIX hosts");
 
-/** @brief Internal function to create a SIMIX host. */
-void SIMIX_host_create(sg_host_t host) // FIXME: braindead prototype. Take sg_host as parameter
-{
-  smx_host_priv_t smx_host = xbt_new0(s_smx_host_priv_t, 1);
+namespace simgrid {
+  namespace simix {
+    simgrid::xbt::Extension<simgrid::s4u::Host, Host> Host::EXTENSION_ID;
+
+    Host::Host()
+    {
+      if (!EXTENSION_ID.valid())
+        EXTENSION_ID = simgrid::s4u::Host::extension_create<simgrid::simix::Host>();
 
-  /* Host structure */
-  simgrid::simix::ActorImpl proc;
-  smx_host->process_list = xbt_swag_new(xbt_swag_offset(proc, host_proc_hookup));
+      simgrid::simix::ActorImpl act;
+      process_list = xbt_swag_new(xbt_swag_offset(act, host_proc_hookup));
+    }
 
-  /* Update global variables */
-  sg_host_simix_set(host, smx_host);
+    Host::~Host()
+    {
+      /* Clean Simulator data */
+      if (xbt_swag_size(process_list) != 0) {
+        char *msg = xbt_strdup("Shutting down host, but it's not empty:");
+        char *tmp;
+        smx_actor_t process = nullptr;
+
+        xbt_swag_foreach(process, process_list) {
+          tmp = bprintf("%s\n\t%s", msg, process->name.c_str());
+          free(msg);
+          msg = tmp;
+        }
+        SIMIX_display_process_status();
+        THROWF(arg_error, 0, "%s", msg);
+      }
+      xbt_dynar_free(&auto_restart_processes);
+      xbt_dynar_free(&boot_processes);
+      xbt_swag_free(process_list);
+    }
+  }
 }
 
 /** @brief Start the host if it is off */
@@ -94,40 +117,6 @@ void SIMIX_host_off(sg_host_t h, smx_actor_t issuer)
   }
 }
 
-/**
- * \brief Internal function to destroy a SIMIX host.
- *
- * \param h the host to destroy (a sg_host_t)
- */
-void SIMIX_host_destroy(void *h)
-{
-  smx_host_priv_t host = static_cast<smx_host_priv_t>(h);
-
-  xbt_assert((host != nullptr), "Invalid parameters");
-
-  /* Clean Simulator data */
-  if (xbt_swag_size(host->process_list) != 0) {
-    char *msg = xbt_strdup("Shutting down host, but it's not empty:");
-    char *tmp;
-    smx_actor_t process = nullptr;
-
-    xbt_swag_foreach(process, host->process_list) {
-      tmp = bprintf("%s\n\t%s", msg, process->name.c_str());
-      free(msg);
-      msg = tmp;
-    }
-    SIMIX_display_process_status();
-    THROWF(arg_error, 0, "%s", msg);
-  }
-  xbt_dynar_free(&host->auto_restart_processes);
-  xbt_dynar_free(&host->boot_processes);
-  xbt_swag_free(host->process_list);
-
-  /* Clean host structure */
-  free(host);
-  return;
-}
-
 sg_host_t SIMIX_host_self()
 {
   smx_actor_t process = SIMIX_process_self();