Logo AND Algorithmique Numérique Distribuée

Public GIT Repository
[SIMIX] Move std::function<void()> to simgrid::simix::ActorCode
[simgrid.git] / src / simix / smx_host.cpp
index 3e9573a..ecd8634 100644 (file)
@@ -61,29 +61,6 @@ namespace simgrid {
 
 }} // namespaces
 
-/** @brief Stop the host if it is on */
-void SIMIX_host_off(sg_host_t h, smx_actor_t issuer)
-{
-  simgrid::simix::Host* host = h->extension<simgrid::simix::Host>();
-
-  xbt_assert((host != nullptr), "Invalid parameters");
-
-  if (h->isOn()) {
-    h->pimpl_cpu->turn_off();
-
-    /* Clean Simulator data */
-    if (not host->process_list.empty()) {
-      for (auto& process : host->process_list) {
-        SIMIX_process_kill(&process, issuer);
-        XBT_DEBUG("Killing %s@%s on behalf of %s which turned off that host.", process.get_cname(),
-                  process.host->get_cname(), issuer->get_cname());
-      }
-    }
-  } else {
-    XBT_INFO("Host %s is already off", h->get_cname());
-  }
-}
-
 /* needs to be public and without simcall for exceptions and logging events */
 const char* sg_host_self_get_name()
 {
@@ -101,15 +78,15 @@ const char* sg_host_self_get_name()
  * The processes will only be restarted once, meaning that you will have to register the process
  * again to restart the process again.
  */
-void SIMIX_host_add_auto_restart_process(sg_host_t host, const char* name, std::function<void()> code, void* data,
-                                         double kill_time, std::map<std::string, std::string>* properties,
+void SIMIX_host_add_auto_restart_process(sg_host_t host, const char* name, simgrid::simix::ActorCode code, void* data,
+                                         double kill_time, std::unordered_map<std::string, std::string>* properties,
                                          int auto_restart)
 {
   simgrid::kernel::actor::ProcessArg* arg =
       new simgrid::kernel::actor::ProcessArg(name, code, data, host, kill_time, nullptr, auto_restart);
   arg->properties.reset(properties, [](decltype(properties)) {});
 
-  if (host->isOff() && watched_hosts.find(host->get_cname()) == watched_hosts.end()) {
+  if (host->is_off() && watched_hosts.find(host->get_cname()) == watched_hosts.end()) {
     watched_hosts.insert(host->get_cname());
     XBT_DEBUG("Push host %s to watched_hosts because state == SURF_RESOURCE_OFF", host->get_cname());
   }
@@ -255,7 +232,7 @@ void SIMIX_execution_finish(smx_activity_t synchro)
         xbt_die("Internal error in SIMIX_execution_finish: unexpected synchro state %d", (int)exec->state_);
     }
     /* Fail the process if the host is down */
-    if (simcall->issuer->host->isOff())
+    if (simcall->issuer->host->is_off())
       simcall->issuer->context->iwannadie = 1;
 
     simcall->issuer->waiting_synchro = nullptr;