Logo AND Algorithmique Numérique Distribuée

Public GIT Repository
boot_processes_ vector becomes actors_at_boot_ map
authorFrederic Suter <frederic.suter@cc.in2p3.fr>
Sun, 5 Aug 2018 10:24:29 +0000 (12:24 +0200)
committerFrederic Suter <frederic.suter@cc.in2p3.fr>
Sun, 5 Aug 2018 18:54:59 +0000 (20:54 +0200)
src/surf/HostImpl.cpp
src/surf/HostImpl.hpp
src/surf/sg_platf.cpp

index 1084bc0..d6235f4 100644 (file)
@@ -102,6 +102,7 @@ HostImpl::HostImpl(s4u::Host* host) : piface_(host)
   delete piface_->pimpl_;
   piface_->pimpl_ = this;
 }
+
 HostImpl::~HostImpl()
 {
   /* All processes should be gone when the host is turned off (by the end of the simulation). */
@@ -116,9 +117,9 @@ HostImpl::~HostImpl()
   for (auto const& arg : auto_restart_processes_)
     delete arg;
   auto_restart_processes_.clear();
-  for (auto const& arg : boot_processes_)
-    delete arg;
-  boot_processes_.clear();
+  for (auto const& arg : actors_at_boot_)
+    delete arg.second;
+  actors_at_boot_.clear();
 }
 
 /** Re-starts all the actors that are marked as restartable.
@@ -127,8 +128,9 @@ HostImpl::~HostImpl()
  */
 void HostImpl::turn_on()
 {
-  for (auto const& arg : boot_processes_) {
-    XBT_DEBUG("Booting Process %s(%s) right now", arg->name.c_str(), arg->host->get_cname());
+  for (auto const& elm : actors_at_boot_) {
+    kernel::actor::ProcessArg* arg = elm.second;
+    XBT_DEBUG("Booting Actor %s(%s) right now", arg->name.c_str(), arg->host->get_cname());
     smx_actor_t actor = simix_global->create_process_function(arg->name.c_str(), arg->code, nullptr, arg->host,
                                                               arg->properties.get(), nullptr);
     if (arg->kill_time >= 0)
@@ -142,9 +144,9 @@ void HostImpl::turn_off()
 {
   if (not process_list_.empty()) {
     for (auto& actor : process_list_) {
-      SIMIX_process_kill(&actor, SIMIX_process_self());
-      XBT_DEBUG("Killing %s@%s on behalf of %s which turned off that host.", actor.get_cname(),
+      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());
+      SIMIX_process_kill(&actor, SIMIX_process_self());
     }
   }
 }
index 6672d7a..3ed2abb 100644 (file)
@@ -67,7 +67,7 @@ public:
   // FIXME: make these private
   ActorList process_list_;
   std::vector<kernel::actor::ProcessArg*> auto_restart_processes_;
-  std::vector<kernel::actor::ProcessArg*> boot_processes_;
+  std::map<std::string, kernel::actor::ProcessArg*> actors_at_boot_;
 };
 }
 }
index a3a9c52..55de705 100644 (file)
@@ -444,7 +444,7 @@ void sg_platf_new_actor(simgrid::kernel::routing::ActorCreationArgs* actor)
   simgrid::kernel::actor::ProcessArg* arg =
       new simgrid::kernel::actor::ProcessArg(actor_name, code, nullptr, host, kill_time, properties, auto_restart);
 
-  host->pimpl_->boot_processes_.push_back(arg);
+  host->pimpl_->actors_at_boot_.insert({actor_name, arg});
 
   if (start_time > SIMIX_get_clock()) {