Logo AND Algorithmique Numérique Distribuée

Public GIT Repository
Register ExecImpls with ActorImpl.
authorArnaud Giersch <arnaud.giersch@univ-fcomte.fr>
Thu, 12 Mar 2020 13:34:46 +0000 (14:34 +0100)
committerArnaud Giersch <arnaud.giersch@univ-fcomte.fr>
Thu, 12 Mar 2020 14:37:56 +0000 (15:37 +0100)
This allows to cancel running exec e.g., when an actor is killed.

src/kernel/activity/ExecImpl.cpp
src/kernel/activity/ExecImpl.hpp

index 80127ed..29b0ed4 100644 (file)
@@ -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();
 }
index b233677..b7ae692 100644 (file)
@@ -17,6 +17,7 @@ namespace activity {
 class XBT_PUBLIC ExecImpl : public ActivityImpl_T<ExecImpl> {
   std::unique_ptr<resource::Action, std::function<void(resource::Action*)>> timeout_detector_{
       nullptr, [](resource::Action* a) { a->unref(); }};
+  actor::ActorImpl* actor_            = nullptr;
   double sharing_penalty_             = 1.0;
   double bound_                       = 0.0;
   std::vector<s4u::Host*> hosts_;
@@ -24,6 +25,8 @@ class XBT_PUBLIC ExecImpl : public ActivityImpl_T<ExecImpl> {
   std::vector<double> bytes_amounts_;
 
 public:
+  ExecImpl();
+
   ExecImpl& set_timeout(double timeout) override;
   ExecImpl& set_bound(double bound);
   ExecImpl& set_sharing_penalty(double sharing_penalty);