Logo AND Algorithmique Numérique Distribuée

Public GIT Repository
somehow smpif90 was not handling trace_call_location at all.
[simgrid.git] / src / s4u / s4u_Exec.cpp
index 71368f7..57ea18a 100644 (file)
@@ -3,14 +3,14 @@
 /* This program is free software; you can redistribute it and/or modify it
  * under the terms of the license (GNU LGPL) which comes with this package. */
 
-#include "simgrid/Exception.hpp"
-#include "simgrid/exec.h"
-#include "simgrid/s4u/Actor.hpp"
-#include "simgrid/s4u/Exec.hpp"
+#include <simgrid/Exception.hpp>
+#include <simgrid/exec.h>
+#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"
-#include "xbt/log.h"
 
 XBT_LOG_NEW_DEFAULT_SUBCATEGORY(s4u_exec, s4u_activity, "S4U asynchronous executions");
 
@@ -33,6 +33,14 @@ void Exec::complete(Activity::State state)
 ExecPtr Exec::init()
 {
   auto pimpl = kernel::activity::ExecImplPtr(new kernel::activity::ExecImpl());
+  unsigned int cb_id = 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();
+    }
+  });
+  pimpl->set_cb_id(cb_id);
   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,