X-Git-Url: http://bilbo.iut-bm.univ-fcomte.fr/pub/gitweb/simgrid.git/blobdiff_plain/9ceefed14c83a0f6ea5f78e3acafd53181dc4fa1..f9b13d923d31bb0336aeeaab6d5b7ba33812f3f7:/src/s4u/s4u_Exec.cpp diff --git a/src/s4u/s4u_Exec.cpp b/src/s4u/s4u_Exec.cpp index 4efdc11290..14f8e74dcf 100644 --- a/src/s4u/s4u_Exec.cpp +++ b/src/s4u/s4u_Exec.cpp @@ -1,4 +1,4 @@ -/* Copyright (c) 2006-2021. The SimGrid Team. All rights reserved. */ +/* Copyright (c) 2006-2022. 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. */ @@ -23,7 +23,7 @@ Exec::Exec(kernel::activity::ExecImplPtr pimpl) pimpl_ = pimpl; } -void Exec::reset() +void Exec::reset() const { boost::static_pointer_cast(pimpl_)->reset(); } @@ -32,9 +32,9 @@ 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 && + 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->state_ = kernel::activity::State::FAILED; + pimpl->set_state(kernel::activity::State::FAILED); pimpl->post(); } }); @@ -61,20 +61,10 @@ Exec* Exec::start() ssize_t Exec::wait_any_for(const std::vector& execs, double timeout) { - std::vector rexecs(execs.size()); - std::transform(begin(execs), end(execs), begin(rexecs), - [](const ExecPtr& exec) { return static_cast(exec->pimpl_.get()); }); - - kernel::actor::ActorImpl* issuer = kernel::actor::ActorImpl::self(); - kernel::actor::ExecutionWaitanySimcall observer{issuer, rexecs, timeout}; - ssize_t changed_pos = kernel::actor::simcall_blocking( - [&observer] { - kernel::activity::ExecImpl::wait_any_for(observer.get_issuer(), observer.get_execs(), observer.get_timeout()); - }, - &observer); - if (changed_pos != -1) - execs.at(changed_pos)->complete(State::FINISHED); - return changed_pos; + std::vector activities; + for (const auto& exec : execs) + activities.push_back(boost::dynamic_pointer_cast(exec)); + return Activity::wait_any_for(activities, timeout); } /** @brief change the execution bound @@ -159,16 +149,6 @@ unsigned int Exec::get_host_number() const return static_cast(pimpl_.get())->get_host_number(); } -double Exec::get_start_time() const -{ - return static_cast(pimpl_.get())->get_start_time(); -} - -double Exec::get_finish_time() const -{ - return static_cast(pimpl_.get())->get_finish_time(); -} - /** @brief Change the host on which this activity takes place. * * The activity cannot be terminated already (but it may be started). */