Logo AND Algorithmique Numérique Distribuée

Public GIT Repository
Make field 'Context::iwannadie' private.
authorArnaud Giersch <arnaud.giersch@univ-fcomte.fr>
Wed, 15 Jan 2020 20:47:05 +0000 (21:47 +0100)
committerArnaud Giersch <arnaud.giersch@univ-fcomte.fr>
Thu, 16 Jan 2020 09:27:49 +0000 (10:27 +0100)
I'm not fond of the names for the new methods, but don't have a better idea.

src/kernel/activity/CommImpl.cpp
src/kernel/activity/ExecImpl.cpp
src/kernel/activity/IoImpl.cpp
src/kernel/activity/SynchroRaw.cpp
src/kernel/actor/ActorImpl.cpp
src/kernel/context/Context.hpp
src/simix/popping_generated.cpp
src/simix/simcalls.py

index b37cd5d..b80dc64 100644 (file)
@@ -607,7 +607,7 @@ void CommImpl::finish()
     /* Check out for errors */
 
     if (not simcall->issuer_->get_host()->is_on()) {
-      simcall->issuer_->context_->iwannadie = true;
+      simcall->issuer_->context_->set_wannadie();
     } else {
       switch (state_) {
         case State::DONE:
@@ -627,7 +627,7 @@ void CommImpl::finish()
 
         case State::SRC_HOST_FAILURE:
           if (simcall->issuer_ == src_actor_)
-            simcall->issuer_->context_->iwannadie = true;
+            simcall->issuer_->context_->set_wannadie();
           else
             simcall->issuer_->exception_ =
                 std::make_exception_ptr(simgrid::NetworkFailureException(XBT_THROW_POINT, "Remote peer failed"));
@@ -635,7 +635,7 @@ void CommImpl::finish()
 
         case State::DST_HOST_FAILURE:
           if (simcall->issuer_ == dst_actor_)
-            simcall->issuer_->context_->iwannadie = true;
+            simcall->issuer_->context_->set_wannadie();
           else
             simcall->issuer_->exception_ =
                 std::make_exception_ptr(simgrid::NetworkFailureException(XBT_THROW_POINT, "Remote peer failed"));
index e5204d7..5ab240d 100644 (file)
@@ -252,7 +252,7 @@ void ExecImpl::finish()
 
       case State::FAILED:
         XBT_DEBUG("ExecImpl::finish(): host '%s' failed", simcall->issuer_->get_host()->get_cname());
-        simcall->issuer_->context_->iwannadie = true;
+        simcall->issuer_->context_->set_wannadie();
         if (simcall->issuer_->get_host()->is_on())
           simcall->issuer_->exception_ =
               std::make_exception_ptr(simgrid::HostFailureException(XBT_THROW_POINT, "Host failed"));
@@ -279,7 +279,7 @@ void ExecImpl::finish()
     if (simcall->issuer_->get_host()->is_on())
       simcall->issuer_->simcall_answer();
     else
-      simcall->issuer_->context_->iwannadie = true;
+      simcall->issuer_->context_->set_wannadie();
   }
 }
 
index be073a7..ce4254f 100644 (file)
@@ -140,7 +140,7 @@ void IoImpl::finish()
         /* do nothing, synchro done */
         break;
       case State::FAILED:
-        simcall->issuer_->context_->iwannadie = true;
+        simcall->issuer_->context_->set_wannadie();
         simcall->issuer_->exception_ =
             std::make_exception_ptr(StorageFailureException(XBT_THROW_POINT, "Storage failed"));
         break;
index 6b1aeca..171199b 100644 (file)
@@ -71,7 +71,7 @@ void RawImpl::finish()
 
   if (state_ == State::FAILED) {
     XBT_DEBUG("RawImpl::finish(): host '%s' failed", simcall->issuer_->get_host()->get_cname());
-    simcall->issuer_->context_->iwannadie = true;
+    simcall->issuer_->context_->set_wannadie();
     simcall->issuer_->exception_ = std::make_exception_ptr(HostFailureException(XBT_THROW_POINT, "Host failed"));
   } else if (state_ != State::SRC_TIMEOUT) {
     xbt_die("Internal error in RawImpl::finish() unexpected synchro state %d", static_cast<int>(state_));
index d9ef6c1..621c4c1 100644 (file)
@@ -157,7 +157,7 @@ void ActorImpl::cleanup()
 
   if (on_exit) {
     // Execute the termination callbacks
-    bool failed = context_->iwannadie;
+    bool failed = context_->wannadie();
     for (auto exit_fun = on_exit->crbegin(); exit_fun != on_exit->crend(); ++exit_fun)
       (*exit_fun)(failed);
     on_exit.reset();
@@ -183,14 +183,14 @@ void ActorImpl::cleanup()
   }
   cleanup_from_simix();
 
-  context_->iwannadie = false; // don't let the simcall's yield() do a Context::stop(), to avoid infinite loops
+  context_->set_wannadie(false); // don't let the simcall's yield() do a Context::stop(), to avoid infinite loops
   actor::simcall([this] { s4u::Actor::on_termination(*ciface()); });
-  context_->iwannadie = true;
+  context_->set_wannadie();
 }
 
 void ActorImpl::exit()
 {
-  context_->iwannadie = true;
+  context_->set_wannadie();
   suspended_          = false;
   exception_          = nullptr;
 
@@ -276,7 +276,7 @@ void ActorImpl::yield()
   /* Ok, maestro returned control to us */
   XBT_DEBUG("Control returned to me: '%s'", get_cname());
 
-  if (context_->iwannadie) {
+  if (context_->wannadie()) {
     XBT_DEBUG("Actor %s@%s is dead", get_cname(), host_->get_cname());
     context_->stop();
     THROW_IMPOSSIBLE;
@@ -371,7 +371,7 @@ void ActorImpl::resume()
 {
   XBT_IN("actor = %p", this);
 
-  if (context_->iwannadie) {
+  if (context_->wannadie()) {
     XBT_VERB("Ignoring request to suspend an actor that is currently dying.");
     return;
   }
index eb44e76..e4f3d66 100644 (file)
@@ -45,16 +45,17 @@ class XBT_PUBLIC Context {
 
   std::function<void()> code_;
   actor::ActorImpl* actor_ = nullptr;
+  bool iwannadie_          = false;
   void declare_context(std::size_t size);
 
 public:
-  bool iwannadie = false;
-
   Context(std::function<void()>&& code, actor::ActorImpl* actor);
   Context(const Context&) = delete;
   Context& operator=(const Context&) = delete;
   virtual ~Context();
 
+  bool wannadie() const { return iwannadie_; }
+  void set_wannadie(bool value = true) { iwannadie_ = value; }
   void operator()() { code_(); }
   bool has_code() const { return static_cast<bool>(code_); }
   actor::ActorImpl* get_actor() { return this->actor_; }
index b3db833..8d4fd42 100644 (file)
@@ -59,7 +59,7 @@ const char* simcall_names[] = {
 void simgrid::kernel::actor::ActorImpl::simcall_handle(int value) {
   XBT_DEBUG("Handling simcall %p: %s", &simcall, SIMIX_simcall_name(simcall.call_));
   SIMCALL_SET_MC_VALUE(simcall, value);
-  if (context_->iwannadie)
+  if (context_->wannadie())
     return;
   switch (simcall.call_) {
     case SIMCALL_EXECUTION_WAIT:
index 66d358f..36fa58d 100755 (executable)
@@ -344,7 +344,7 @@ if __name__ == '__main__':
         '  XBT_DEBUG("Handling simcall %p: %s", &simcall, SIMIX_simcall_name(simcall.call_));\n')
     fd.write('  SIMCALL_SET_MC_VALUE(simcall, value);\n')
     fd.write(
-        '  if (context_->iwannadie)\n')
+        '  if (context_->wannadie())\n')
     fd.write('    return;\n')
     fd.write('  switch (simcall.call_) {\n')