X-Git-Url: http://bilbo.iut-bm.univ-fcomte.fr/pub/gitweb/simgrid.git/blobdiff_plain/7672ae43c2b49a7dcdc0976cc89a05cc87ae534c..cd5185ae774cc99650b6cae2dca17b6062accea3:/src/s4u/s4u_Exec.cpp diff --git a/src/s4u/s4u_Exec.cpp b/src/s4u/s4u_Exec.cpp index 24946989ec..a6fd9cb3ca 100644 --- a/src/s4u/s4u_Exec.cpp +++ b/src/s4u/s4u_Exec.cpp @@ -1,4 +1,4 @@ -/* Copyright (c) 2006-2022. The SimGrid Team. All rights reserved. */ +/* Copyright (c) 2006-2023. The SimGrid Team. All rights reserved. */ /* 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. */ @@ -16,7 +16,6 @@ XBT_LOG_NEW_DEFAULT_SUBCATEGORY(s4u_exec, s4u_activity, "S4U asynchronous executions"); namespace simgrid::s4u { -xbt::signal Exec::on_start; Exec::Exec(kernel::activity::ExecImplPtr pimpl) { @@ -31,18 +30,10 @@ void Exec::reset() const 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(pimpl->get_iface())); } -Exec* Exec::start() +Exec* Exec::do_start() { kernel::actor::simcall_answered([this] { (*boost::static_pointer_cast(pimpl_)) @@ -56,6 +47,7 @@ Exec* Exec::start() state_ = State::STARTED; on_start(*this); + on_this_start(*this); return this; } @@ -180,8 +172,8 @@ ExecPtr Exec::set_host(Host* host) pimpl_.get(), [this, host] { boost::static_pointer_cast(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; } @@ -198,7 +190,7 @@ ExecPtr Exec::set_hosts(const std::vector& hosts) // Setting the host may allow to start the activity, let's try if (state_ == State::STARTING) - vetoable_start(); + start(); return this; } @@ -213,7 +205,7 @@ ExecPtr Exec::unset_host() if (state_ == State::STARTED) cancel(); - vetoable_start(); + start(); return this; } @@ -221,7 +213,7 @@ ExecPtr Exec::unset_host() 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 @@ -287,7 +279,7 @@ double sg_exec_get_remaining_ratio(const_sg_exec_t exec) void sg_exec_start(sg_exec_t exec) { - exec->vetoable_start(); + exec->start(); } void sg_exec_cancel(sg_exec_t exec)