- if (is_parallel())
- kernel::actor::simcall([this] {
- (*boost::static_pointer_cast<kernel::activity::ExecImpl>(pimpl_))
- .set_hosts(hosts_)
- .set_timeout(timeout_)
- .set_flops_amounts(flops_amounts_)
- .set_bytes_amounts(bytes_amounts_)
- .start();
- });
- else
- kernel::actor::simcall([this] {
- (*boost::static_pointer_cast<kernel::activity::ExecImpl>(pimpl_))
- .set_name(get_name())
- .set_tracing_category(get_tracing_category())
- .set_sharing_penalty(1. / priority_)
- .set_bound(bound_)
- .set_flops_amount(flops_amounts_.front())
- .start();
- });
- state_ = State::STARTED;
- on_start(*Actor::self(), *this);
- return this;
+ if (not is_assigned())
+ throw std::invalid_argument(
+ xbt::string_printf("Exec %s: the activity is not assigned to any host(s)", get_cname()));
+ else {
+ reset();
+
+ if (state_ == State::STARTED)
+ cancel();
+ start();
+
+ return this;
+ }
+}
+
+double Exec::get_cost() const
+{
+ return (pimpl_->model_action_ == nullptr) ? -1 : pimpl_->model_action_->get_cost();