XBT_LOG_NEW_DEFAULT_SUBCATEGORY(s4u_exec, s4u_activity, "S4U asynchronous executions");
namespace simgrid::s4u {
-xbt::signal<void(Exec const&)> Exec::on_start;
Exec::Exec(kernel::activity::ExecImplPtr pimpl)
{
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->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->post();
- }
- });
- pimpl->set_cb_id(cb_id);
return ExecPtr(static_cast<Exec*>(pimpl->get_iface()));
}
-Exec* Exec::start()
+Exec* Exec::do_start()
{
kernel::actor::simcall_answered([this] {
(*boost::static_pointer_cast<kernel::activity::ExecImpl>(pimpl_))
state_ = State::STARTED;
on_start(*this);
+ on_this_start(*this);
return this;
}
pimpl_.get(), [this, host] { boost::static_pointer_cast<kernel::activity::ExecImpl>(pimpl_)->set_host(host); });
if (state_ == State::STARTING)
- // Setting the host may allow to start the activity, let's try
- vetoable_start();
+ // Setting the host may allow to start the activity, let's try
+ start();
return this;
}
// Setting the host may allow to start the activity, let's try
if (state_ == State::STARTING)
- vetoable_start();
+ start();
return this;
}
if (state_ == State::STARTED)
cancel();
- vetoable_start();
+ start();
return this;
}
double Exec::get_cost() const
{
- return (pimpl_->surf_action_ == nullptr) ? -1 : pimpl_->surf_action_->get_cost();
+ return (pimpl_->model_action_ == nullptr) ? -1 : pimpl_->model_action_->get_cost();
}
double Exec::get_remaining() const
void sg_exec_start(sg_exec_t exec)
{
- exec->vetoable_start();
+ exec->start();
}
void sg_exec_cancel(sg_exec_t exec)