Logo AND Algorithmique Numérique Distribuée

Public GIT Repository
Snake case.
[simgrid.git] / src / surf / HostImpl.cpp
index 8983db7..ff008ba 100644 (file)
@@ -13,7 +13,7 @@ XBT_LOG_NEW_DEFAULT_SUBCATEGORY(surf_host, surf, "Logging specific to the SURF h
 simgrid::surf::HostModel *surf_host_model = nullptr;
 
 /*************
- * Callbacks *
+ * Callbacks *t
  *************/
 
 namespace simgrid {
@@ -22,7 +22,6 @@ namespace surf {
 /*********
  * Model *
  *********/
-
 /* Helper function for executeParallelTask */
 static inline double has_cost(const double* array, size_t pos)
 {
@@ -32,20 +31,20 @@ static inline double has_cost(const double* array, size_t pos)
     return -1.0;
 }
 
-kernel::resource::Action* HostModel::execute_parallel(size_t host_nb, s4u::Host* const* host_list,
+kernel::resource::Action* HostModel::execute_parallel(const std::vector<s4u::Host*>& host_list,
                                                       const double* flops_amount, const double* bytes_amount,
                                                       double rate)
 {
   kernel::resource::Action* action = nullptr;
-  if ((host_nb == 1) && (has_cost(bytes_amount, 0) <= 0) && (has_cost(flops_amount, 0) > 0)) {
+  if ((host_list.size() == 1) && (has_cost(bytes_amount, 0) <= 0) && (has_cost(flops_amount, 0) > 0)) {
     action = host_list[0]->pimpl_cpu->execution_start(flops_amount[0]);
-  } else if ((host_nb == 1) && (has_cost(flops_amount, 0) <= 0)) {
+  } else if ((host_list.size() == 1) && (has_cost(flops_amount, 0) <= 0)) {
     action = surf_network_model->communicate(host_list[0], host_list[0], bytes_amount[0], rate);
-  } else if ((host_nb == 2) && (has_cost(flops_amount, 0) <= 0) && (has_cost(flops_amount, 1) <= 0)) {
+  } else if ((host_list.size() == 2) && (has_cost(flops_amount, 0) <= 0) && (has_cost(flops_amount, 1) <= 0)) {
     int nb = 0;
     double value = 0.0;
 
-    for (size_t i = 0; i < host_nb * host_nb; i++) {
+    for (size_t i = 0; i < host_list.size() * host_list.size(); i++) {
       if (has_cost(bytes_amount, i) > 0.0) {
         nb++;
         value = has_cost(bytes_amount, i);
@@ -106,10 +105,12 @@ void HostImpl::turn_on()
     XBT_DEBUG("Booting Actor %s(%s) right now", arg->name.c_str(), arg->host->get_cname());
     simgrid::kernel::actor::ActorImplPtr actor = simgrid::kernel::actor::ActorImpl::create(
         arg->name.c_str(), arg->code, nullptr, arg->host, arg->properties.get(), nullptr);
+    if (arg->on_exit)
+      *actor->on_exit = *arg->on_exit;
     if (arg->kill_time >= 0)
       actor->set_kill_time(arg->kill_time);
     if (arg->auto_restart)
-      actor->auto_restart_ = arg->auto_restart;
+      actor->set_auto_restart(arg->auto_restart);
     if (arg->daemon_)
       actor->daemonize();
   }
@@ -121,7 +122,7 @@ void HostImpl::turn_off()
   if (not process_list_.empty()) {
     for (auto& actor : process_list_) {
       XBT_DEBUG("Killing Actor %s@%s on behalf of %s which turned off that host.", actor.get_cname(),
-                actor.host_->get_cname(), SIMIX_process_self()->get_cname());
+                actor.get_host()->get_cname(), SIMIX_process_self()->get_cname());
       SIMIX_process_self()->kill(&actor);
     }
   }
@@ -151,7 +152,7 @@ std::vector<const char*> HostImpl::get_attached_storages()
 {
   std::vector<const char*> storages;
   for (auto const& s : storage_)
-    if (s.second->getHost() == piface_->get_cname())
+    if (s.second->get_host() == piface_->get_cname())
       storages.push_back(s.second->piface_.get_cname());
   return storages;
 }