From: Arnaud Giersch Date: Thu, 12 Mar 2020 13:34:46 +0000 (+0100) Subject: Register ExecImpls with ActorImpl. X-Git-Tag: v3.26~743 X-Git-Url: http://info.iut-bm.univ-fcomte.fr/pub/gitweb/simgrid.git/commitdiff_plain/fd3eb2f5d0d3fe54889995b18df1c982eff3f629 Register ExecImpls with ActorImpl. This allows to cancel running exec e.g., when an actor is killed. --- diff --git a/src/kernel/activity/ExecImpl.cpp b/src/kernel/activity/ExecImpl.cpp index 80127ed919..29b0ed4459 100644 --- a/src/kernel/activity/ExecImpl.cpp +++ b/src/kernel/activity/ExecImpl.cpp @@ -55,6 +55,15 @@ namespace simgrid { namespace kernel { namespace activity { +ExecImpl::ExecImpl() +{ + actor::ActorImpl* self = actor::ActorImpl::self(); + if (self) { + actor_ = self; + self->activities.push_back(this); + } +} + ExecImpl& ExecImpl::set_host(s4u::Host* host) { hosts_.assign(1, host); @@ -156,6 +165,10 @@ void ExecImpl::post() clean_action(); timeout_detector_.reset(); + if (actor_) { + actor_->activities.remove(this); + actor_ = nullptr; + } /* Answer all simcalls associated with the synchro */ finish(); } diff --git a/src/kernel/activity/ExecImpl.hpp b/src/kernel/activity/ExecImpl.hpp index b233677154..b7ae692a30 100644 --- a/src/kernel/activity/ExecImpl.hpp +++ b/src/kernel/activity/ExecImpl.hpp @@ -17,6 +17,7 @@ namespace activity { class XBT_PUBLIC ExecImpl : public ActivityImpl_T { std::unique_ptr> timeout_detector_{ nullptr, [](resource::Action* a) { a->unref(); }}; + actor::ActorImpl* actor_ = nullptr; double sharing_penalty_ = 1.0; double bound_ = 0.0; std::vector hosts_; @@ -24,6 +25,8 @@ class XBT_PUBLIC ExecImpl : public ActivityImpl_T { std::vector bytes_amounts_; public: + ExecImpl(); + ExecImpl& set_timeout(double timeout) override; ExecImpl& set_bound(double bound); ExecImpl& set_sharing_penalty(double sharing_penalty);