Logo AND Algorithmique Numérique Distribuée

Public GIT Repository
ActorImpl::join: react right away if the other actor is already dead
authorMartin Quinson <martin.quinson@ens-rennes.fr>
Sat, 12 Mar 2022 18:03:51 +0000 (19:03 +0100)
committerMartin Quinson <martin.quinson@ens-rennes.fr>
Sun, 13 Mar 2022 14:30:06 +0000 (15:30 +0100)
src/kernel/actor/ActorImpl.cpp

index e1af046..f62d97c 100644 (file)
@@ -375,10 +375,15 @@ void ActorImpl::resume()
 activity::ActivityImplPtr ActorImpl::join(const ActorImpl* actor, double timeout)
 {
   activity::ActivityImplPtr sleep = this->sleep(timeout);
-  actor->on_exit->emplace_back([sleep](bool) {
+  if (actor->context_->wannadie() || actor->context_->to_be_freed()) {
     if (sleep->surf_action_)
       sleep->surf_action_->finish(resource::Action::State::FINISHED);
-  });
+  } else {
+    actor->on_exit->emplace_back([sleep](bool) {
+      if (sleep->surf_action_)
+        sleep->surf_action_->finish(resource::Action::State::FINISHED);
+    });
+  }
   return sleep;
 }