Logo AND Algorithmique Numérique Distribuée

Public GIT Repository
Simplify the way Execs detect host failures
authorMartin Quinson <martin.quinson@ens-rennes.fr>
Sat, 25 Feb 2023 17:40:49 +0000 (18:40 +0100)
committerMartin Quinson <martin.quinson@ens-rennes.fr>
Sat, 25 Feb 2023 17:40:54 +0000 (18:40 +0100)
Have the ExecImpl install the callback instead of having the s4u::Exec
do so, and then set an internal field of ExecImpl.

src/kernel/activity/ExecImpl.cpp
src/kernel/activity/ExecImpl.hpp
src/s4u/s4u_Exec.cpp

index 6d66a12..d9badf2 100644 (file)
@@ -88,6 +88,15 @@ ExecImpl* ExecImpl::start()
     set_start_time(model_action_->get_start_time());
   }
 
+  /* Allow execs to fail if any their host fail (or any of their host for parallel execs) */
+  cb_id_ = s4u::Host::on_state_change.connect([this](s4u::Host const& h) {
+    if (not h.is_on() && get_state() == kernel::activity::State::RUNNING &&
+        std::find(get_hosts().begin(), get_hosts().end(), &h) != get_hosts().end()) {
+      set_state(kernel::activity::State::FAILED);
+      finish();
+    }
+  });
+
   XBT_DEBUG("Create execute synchro %p: %s", this, get_cname());
   return this;
 }
index 286bf33..583783a 100644 (file)
@@ -28,8 +28,6 @@ public:
   ExecImpl& set_sharing_penalty(double sharing_penalty);
   ExecImpl& update_sharing_penalty(double sharing_penalty);
 
-  void set_cb_id(unsigned int cb_id) { cb_id_ = cb_id; }
-
   ExecImpl& set_flops_amount(double flop_amount);
   ExecImpl& set_host(s4u::Host* host);
 
index c0fcdc0..3a87ef2 100644 (file)
@@ -31,15 +31,6 @@ void Exec::reset() const
 ExecPtr Exec::init()
 {
   auto pimpl = kernel::activity::ExecImplPtr(new kernel::activity::ExecImpl());
-  /* Allow parallel execs to fail if any of their hosts fail */
-  unsigned int cb_id = Host::on_state_change.connect([pimpl](s4u::Host const& h) {
-    if (not h.is_on() && pimpl->get_state() == kernel::activity::State::RUNNING &&
-        std::find(pimpl->get_hosts().begin(), pimpl->get_hosts().end(), &h) != pimpl->get_hosts().end()) {
-      pimpl->set_state(kernel::activity::State::FAILED);
-      pimpl->finish();
-    }
-  });
-  pimpl->set_cb_id(cb_id);
   return ExecPtr(static_cast<Exec*>(pimpl->get_iface()));
 }