Logo AND Algorithmique Numérique Distribuée

Public GIT Repository
MC: rename remote/Client into remote/AppSide
[simgrid.git] / src / kernel / actor / ActorImpl.cpp
index b8c4318..59ec1c5 100644 (file)
@@ -13,7 +13,7 @@
 #include "src/kernel/activity/SleepImpl.hpp"
 #include "src/kernel/activity/SynchroRaw.hpp"
 #include "src/mc/mc_replay.hpp"
-#include "src/mc/remote/Client.hpp"
+#include "src/mc/remote/AppSide.hpp"
 #include "src/simix/smx_private.hpp"
 #include "src/surf/HostImpl.hpp"
 #include "src/surf/cpu_interface.hpp"
@@ -47,15 +47,16 @@ int get_maxpid()
 
 ActorImpl* ActorImpl::self()
 {
-  context::Context* self_context = context::Context::self();
+  const context::Context* self_context = context::Context::self();
 
   return (self_context != nullptr) ? self_context->get_actor() : nullptr;
 }
 
 ActorImpl::ActorImpl(xbt::string name, s4u::Host* host) : host_(host), name_(std::move(name)), piface_(this)
 {
-  pid_           = maxpid++;
+  pid_            = maxpid++;
   simcall.issuer_ = this;
+  stacksize_      = smx_context_stack_size;
 }
 
 ActorImpl::~ActorImpl()
@@ -165,9 +166,9 @@ void ActorImpl::cleanup()
   undaemonize();
 
   /* cancel non-blocking activities */
-  for (auto activity : comms)
-    boost::static_pointer_cast<activity::CommImpl>(activity)->cancel();
-  comms.clear();
+  for (auto activity : activities)
+    activity->cancel();
+  activities.clear();
 
   XBT_DEBUG("%s@%s(%ld) should not run anymore", get_cname(), get_host()->get_cname(), get_pid());
 
@@ -176,11 +177,16 @@ void ActorImpl::cleanup()
 
   XBT_DEBUG("Cleanup actor %s (%p), waiting synchro %p", get_cname(), this, waiting_synchro.get());
 
-  /* Unregister from the kill timer if any */
+  /* Unregister associated timers if any */
   if (kill_timer != nullptr) {
     kill_timer->remove();
     kill_timer = nullptr;
   }
+  if (simcall.timeout_cb_) {
+    simcall.timeout_cb_->remove();
+    simcall.timeout_cb_ = nullptr;
+  }
+
   cleanup_from_simix();
 
   context_->set_wannadie(false); // don't let the simcall's yield() do a Context::stop(), to avoid infinite loops
@@ -205,7 +211,6 @@ void ActorImpl::exit()
     if (exec != nullptr) {
       exec->clean_action();
     } else if (comm != nullptr) {
-      comms.remove(waiting_synchro);
       // Remove first occurrence of &actor->simcall:
       auto i = boost::range::find(waiting_synchro->simcalls_, &simcall);
       if (i != waiting_synchro->simcalls_.end())
@@ -214,6 +219,7 @@ void ActorImpl::exit()
       activity::ActivityImplPtr(waiting_synchro)->finish();
     }
 
+    activities.remove(waiting_synchro);
     waiting_synchro = nullptr;
   }
 
@@ -421,12 +427,7 @@ void ActorImpl::throw_exception(std::exception_ptr e)
   /* cancel the blocking synchro if any */
   if (waiting_synchro) {
     waiting_synchro->cancel();
-
-    activity::CommImplPtr comm = boost::dynamic_pointer_cast<activity::CommImpl>(waiting_synchro);
-
-    if (comm != nullptr)
-      comms.remove(comm);
-
+    activities.remove(waiting_synchro);
     waiting_synchro = nullptr;
   }
 }