Logo AND Algorithmique Numérique Distribuée

Public GIT Repository
fix destruction order
[simgrid.git] / src / s4u / s4u_Exec.cpp
index 71368f7..ab680d8 100644 (file)
@@ -7,6 +7,7 @@
 #include "simgrid/exec.h"
 #include "simgrid/s4u/Actor.hpp"
 #include "simgrid/s4u/Exec.hpp"
+#include "simgrid/s4u/Host.hpp"
 #include "src/kernel/activity/ExecImpl.hpp"
 #include "src/kernel/actor/ActorImpl.hpp"
 #include "src/kernel/actor/SimcallObserver.hpp"
@@ -33,6 +34,13 @@ void Exec::complete(Activity::State state)
 ExecPtr Exec::init()
 {
   auto pimpl = kernel::activity::ExecImplPtr(new kernel::activity::ExecImpl());
+  Host::on_state_change.connect([pimpl](s4u::Host const& h) {
+    if (not h.is_on() && pimpl->state_ == kernel::activity::State::RUNNING &&
+        std::find(pimpl->get_hosts().begin(), pimpl->get_hosts().end(), &h) != pimpl->get_hosts().end()) {
+      pimpl->state_ = kernel::activity::State::FAILED;
+      pimpl->post();
+    }
+  });
   return ExecPtr(pimpl->get_iface());
 }
 
@@ -100,15 +108,6 @@ ExecPtr Exec::set_priority(double priority)
   return this;
 }
 
-ExecPtr Exec::set_timeout(double timeout) // XBT_ATTRIB_DEPRECATED_v329
-{
-  xbt_assert(state_ == State::INITED || state_ == State::STARTING,
-             "Cannot change the bound of an exec after its start");
-  kernel::actor::simcall(
-      [this, timeout] { boost::static_pointer_cast<kernel::activity::ExecImpl>(pimpl_)->set_timeout(timeout); });
-  return this;
-}
-
 ExecPtr Exec::set_flops_amount(double flops_amount)
 {
   xbt_assert(state_ == State::INITED || state_ == State::STARTING,