explicit Exec(kernel::activity::ExecImplPtr pimpl);
void complete(Activity::State state) override;
+ void reset();
public:
#ifndef DOXYGEN
double get_remaining_ratio() const;
ExecPtr set_host(Host* host);
ExecPtr set_hosts(const std::vector<Host*>& hosts);
+ ExecPtr unset_host();
ExecPtr set_flops_amount(double flops_amount);
ExecPtr set_flops_amounts(const std::vector<double>& flops_amounts);
double ExecImpl::get_remaining() const
{
- if (state_ == State::WAITING)
+ if (state_ == State::WAITING || state_ == State::FAILED)
return flops_amounts_.front();
return ActivityImpl::get_remaining();
}
timeout_detector_.reset();
if (actor_) {
actor_->activities_.remove(this);
- actor_ = nullptr;
}
if (state_ != State::FAILED && cb_id_ >= 0)
s4u::Host::on_state_change.disconnect(cb_id_);
}
}
+void ExecImpl::reset()
+{
+ hosts_.clear();
+ bytes_amounts_.clear();
+ flops_amounts_.clear();
+ start_time_ = -1.0;
+}
+
ActivityImpl* ExecImpl::migrate(s4u::Host* to)
{
if (not MC_is_active() && not MC_record_replay_is_active()) {
void set_exception(actor::ActorImpl* issuer) override;
void finish() override;
+ void reset();
static void wait_any_for(actor::ActorImpl* issuer, const std::vector<ExecImpl*>& execs, double timeout);
static xbt::signal<void(ExecImpl const&, s4u::Host*)> on_migration;
Activity::complete(state);
on_completion(*this);
}
+void Exec::reset()
+{
+ boost::static_pointer_cast<kernel::activity::ExecImpl>(pimpl_)->reset();
+}
ExecPtr Exec::init()
{
return this;
}
+ExecPtr Exec::unset_host()
+{
+ 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();
+ vetoable_start();
+
+ return this;
+ }
+}
+
double Exec::get_cost() const
{
return (pimpl_->surf_action_ == nullptr) ? -1 : pimpl_->surf_action_->get_cost();