/* 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");
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());
}
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,