-/* 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. */
pimpl_ = pimpl;
}
-void Exec::reset()
+void Exec::reset() const
{
boost::static_pointer_cast<kernel::activity::ExecImpl>(pimpl_)->reset();
}
{
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();
}
});
ssize_t Exec::wait_any_for(const std::vector<ExecPtr>& execs, double timeout)
{
- std::vector<kernel::activity::ExecImpl*> rexecs(execs.size());
- std::transform(begin(execs), end(execs), begin(rexecs),
- [](const ExecPtr& exec) { return static_cast<kernel::activity::ExecImpl*>(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<ActivityPtr> activities;
+ for (const auto& exec : execs)
+ activities.push_back(boost::dynamic_pointer_cast<Activity>(exec));
+ return Activity::wait_any_for(activities, timeout);
}
/** @brief change the execution bound
return static_cast<kernel::activity::ExecImpl*>(pimpl_.get())->get_host_number();
}
-double Exec::get_start_time() const
-{
- return static_cast<kernel::activity::ExecImpl*>(pimpl_.get())->get_start_time();
-}
-
-double Exec::get_finish_time() const
-{
- return static_cast<kernel::activity::ExecImpl*>(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). */