Logo AND Algorithmique Numérique Distribuée

Public GIT Repository
make more ActivityImpl fields private
authorSUTER Frederic <frederic.suter@cc.in2p3.fr>
Thu, 13 Jan 2022 08:25:39 +0000 (09:25 +0100)
committerSUTER Frederic <frederic.suter@cc.in2p3.fr>
Thu, 13 Jan 2022 08:25:39 +0000 (09:25 +0100)
16 files changed:
examples/c/actor-exiting/actor-exiting.tesh
examples/cpp/actor-exiting/s4u-actor-exiting.tesh
src/kernel/EngineImpl.cpp
src/kernel/activity/ActivityImpl.hpp
src/kernel/activity/CommImpl.cpp
src/kernel/activity/ExecImpl.cpp
src/kernel/activity/IoImpl.cpp
src/kernel/activity/SleepImpl.cpp
src/kernel/activity/SynchroRaw.cpp
src/kernel/actor/ActorImpl.cpp
src/mc/mc_base.cpp
src/plugins/host_load.cpp
src/s4u/s4u_Comm.cpp
src/s4u/s4u_Exec.cpp
src/s4u/s4u_Mailbox.cpp
src/surf/HostImpl.cpp

index 5833265..0c05238 100644 (file)
@@ -8,6 +8,6 @@ $ ${bindir:=.}/c-actor-exiting ${platfdir}/small_platform.xml "--log=root.fmt:[%
 > [  3.000000] (maestro@) Oops! Deadlock or code not perfectly clean.
 > [  3.000000] (maestro@) 1 actors are still running, waiting for something.
 > [  3.000000] (maestro@) Legend of the following listing: "Actor <pid> (<name>@<host>): <status>"
-> [  3.000000] (maestro@) Actor 3 (C@Ginette): waiting for communication activity 0xdeadbeef () in state 0 to finish
+> [  3.000000] (maestro@) Actor 3 (C@Ginette): waiting for communication activity 0xdeadbeef () in state WAITING to finish
 > [  3.000000] (C@Ginette) I was killed!
 > [  3.000000] (C@Ginette) The backtrace would be displayed here if --log=no_loc would not have been passed
index c26e8bd..c46a118 100644 (file)
@@ -12,7 +12,7 @@ $ ${bindir:=.}/s4u-actor-exiting ${platfdir}/small_platform.xml "--log=root.fmt:
 > [  3.000000] (maestro@) Oops! Deadlock or code not perfectly clean.
 > [  3.000000] (maestro@) 1 actors are still running, waiting for something.
 > [  3.000000] (maestro@) Legend of the following listing: "Actor <pid> (<name>@<host>): <status>"
-> [  3.000000] (maestro@) Actor 3 (C@Ginette): waiting for communication activity 0xdeadbeef () in state 0 to finish
+> [  3.000000] (maestro@) Actor 3 (C@Ginette): waiting for communication activity 0xdeadbeef () in state WAITING to finish
 > [  3.000000] (C@Ginette) I was killed!
 > [  3.000000] (C@Ginette) The backtrace would be displayed here if --log=no_loc would not have been passed
 > [  3.000000] (maestro@) Actor C terminates now
index 3a8229b..16b2c48 100644 (file)
@@ -562,10 +562,10 @@ void EngineImpl::display_all_actor_status() const
       if (boost::dynamic_pointer_cast<kernel::activity::IoImpl>(actor->waiting_synchro_) != nullptr)
         synchro_description = "I/O";
 
-      XBT_INFO("Actor %ld (%s@%s): waiting for %s activity %#zx (%s) in state %d to finish", actor->get_pid(),
+      XBT_INFO("Actor %ld (%s@%s): waiting for %s activity %#zx (%s) in state %s to finish", actor->get_pid(),
                actor->get_cname(), actor->get_host()->get_cname(), synchro_description,
                (xbt_log_no_loc ? (size_t)0xDEADBEEF : (size_t)actor->waiting_synchro_.get()),
-               actor->waiting_synchro_->get_cname(), (int)actor->waiting_synchro_->state_);
+               actor->waiting_synchro_->get_cname(), actor->waiting_synchro_->get_state_str());
     } else {
       XBT_INFO("Actor %ld (%s@%s) simcall %s", actor->get_pid(), actor->get_cname(), actor->get_host()->get_cname(),
                SIMIX_simcall_name(actor->simcall_));
index 9ea9422..33b1101 100644 (file)
@@ -26,17 +26,17 @@ XBT_DECLARE_ENUM_CLASS(State, WAITING, READY, RUNNING, DONE, CANCELED, FAILED, S
 class XBT_PUBLIC ActivityImpl {
   std::atomic_int_fast32_t refcount_{0};
   std::string name_ = "";
+  actor::ActorImpl* actor_ = nullptr;
+  State state_             = State::WAITING; /* State of the activity */
+  double start_time_       = -1.0;
+  double finish_time_      = -1.0;
 
 public:
   virtual ~ActivityImpl();
   ActivityImpl() = default;
-  State state_   = State::WAITING;      /* State of the activity */
   std::list<smx_simcall_t> simcalls_;   /* List of simcalls waiting for this activity */
-  resource::Action* surf_action_ = nullptr;
-  actor::ActorImpl* actor_       = nullptr;
   s4u::Activity* piface_         = nullptr;
-  double start_time_             = -1.0;
-  double finish_time_            = -1.0;
+  resource::Action* surf_action_ = nullptr;
 
 protected:
   void inline set_name(const std::string& name)
@@ -45,6 +45,7 @@ protected:
     // child type
     name_ = name;
   }
+  void set_start_time(double start_time) { start_time_ = start_time; }
 
 public:
   const std::string& get_name() const { return name_; }
@@ -56,6 +57,10 @@ public:
   void set_iface(s4u::Activity* iface) { piface_ = iface; }
   s4u::Activity* get_iface() { return piface_; }
 
+  void set_state(State state) { state_ = state; }
+  const State& get_state() const { return state_; }
+  const char* get_state_str() const;
+
   double get_start_time() const { return start_time_; }
   void set_finish_time(double finish_time) { finish_time_ = finish_time; }
   double get_finish_time() const { return finish_time_; }
@@ -78,7 +83,6 @@ public:
   void unregister_simcall(smx_simcall_t simcall);
   void clean_action();
   virtual double get_remaining() const;
-  const char* get_state_str() const;
   // Support for the boost::intrusive_ptr<ActivityImpl> datatype
   friend XBT_PUBLIC void intrusive_ptr_add_ref(ActivityImpl* activity);
   friend XBT_PUBLIC void intrusive_ptr_release(ActivityImpl* activity);
@@ -91,7 +95,6 @@ public:
  * The difficulty is that set_name() must return a qualified child class, not the generic ancestor
  * But the getter is still in the ancestor to be usable on generic activities with no downcast */
 template <class AnyActivityImpl> class ActivityImpl_T : public ActivityImpl {
-private:
   std::string tracing_category_ = "";
 
 public:
index 6f2f9e0..651167b 100644 (file)
@@ -57,7 +57,7 @@ XBT_PRIVATE simgrid::kernel::activity::ActivityImplPtr simcall_HANDLER_comm_isen
 
     if (mbox->is_permanent()) {
       // this mailbox is for small messages, which have to be sent right now
-      other_comm->state_     = simgrid::kernel::activity::State::READY;
+      other_comm->set_state(simgrid::kernel::activity::State::READY);
       other_comm->dst_actor_ = mbox->get_permanent_receiver().get();
       mbox->push_done(other_comm);
       XBT_DEBUG("pushing a message into the permanent receive list %p, comm %p", mbox, other_comm.get());
@@ -68,7 +68,7 @@ XBT_PRIVATE simgrid::kernel::activity::ActivityImplPtr simcall_HANDLER_comm_isen
   } else {
     XBT_DEBUG("Receive already pushed");
 
-    other_comm->state_ = simgrid::kernel::activity::State::READY;
+    other_comm->set_state(simgrid::kernel::activity::State::READY);
   }
 
   if (detached) {
@@ -88,7 +88,7 @@ XBT_PRIVATE simgrid::kernel::activity::ActivityImplPtr simcall_HANDLER_comm_isen
   other_comm->copy_data_fun = copy_data_fun;
 
   if (MC_is_active() || MC_record_replay_is_active())
-    other_comm->state_ = simgrid::kernel::activity::State::RUNNING;
+    other_comm->set_state(simgrid::kernel::activity::State::RUNNING);
   else
     other_comm->start();
 
@@ -134,7 +134,7 @@ simcall_HANDLER_comm_irecv(smx_simcall_t /*simcall*/, smx_actor_t receiver, smx_
     } else {
       if (other_comm->surf_action_ && other_comm->get_remaining() < 1e-12) {
         XBT_DEBUG("comm %p has been already sent, and is finished, destroy it", other_comm.get());
-        other_comm->state_ = simgrid::kernel::activity::State::DONE;
+        other_comm->set_state(simgrid::kernel::activity::State::DONE);
         other_comm->set_mailbox(nullptr);
       }
     }
@@ -156,7 +156,7 @@ simcall_HANDLER_comm_irecv(smx_simcall_t /*simcall*/, smx_actor_t receiver, smx_
     } else {
       XBT_DEBUG("Match my %p with the existing %p", this_synchro.get(), other_comm.get());
 
-      other_comm->state_ = simgrid::kernel::activity::State::READY;
+      other_comm->set_state(simgrid::kernel::activity::State::READY);
     }
     receiver->activities_.emplace_back(other_comm);
   }
@@ -173,7 +173,7 @@ simcall_HANDLER_comm_irecv(smx_simcall_t /*simcall*/, smx_actor_t receiver, smx_
   other_comm->copy_data_fun = copy_data_fun;
 
   if (MC_is_active() || MC_record_replay_is_active()) {
-    other_comm->state_ = simgrid::kernel::activity::State::RUNNING;
+    other_comm->set_state(simgrid::kernel::activity::State::RUNNING);
     return other_comm;
   }
   other_comm->start();
@@ -276,7 +276,7 @@ CommImpl& CommImpl::detach()
 
 CommImpl::CommImpl(s4u::Host* from, s4u::Host* to, double bytes) : size_(bytes), detached_(true), from_(from), to_(to)
 {
-  state_ = State::READY;
+  set_state(State::READY);
 }
 
 CommImpl::~CommImpl()
@@ -285,7 +285,7 @@ CommImpl::~CommImpl()
 
   cleanup_surf();
 
-  if (detached_ && state_ != State::DONE) {
+  if (detached_ && get_state() != State::DONE) {
     /* the communication has failed and was detached:
      * we have to free the buffer */
     if (clean_fun)
@@ -300,7 +300,7 @@ CommImpl::~CommImpl()
 CommImpl* CommImpl::start()
 {
   /* If both the sender and the receiver are already there, start the communication */
-  if (state_ == State::READY) {
+  if (get_state() == State::READY) {
     from_ = from_ != nullptr ? from_ : src_actor_->get_host();
     to_   = to_ != nullptr ? to_ : dst_actor_->get_host();
     /* Getting the network_model from the origin host
@@ -311,8 +311,8 @@ CommImpl* CommImpl::start()
     surf_action_ = net_model->communicate(from_, to_, size_, rate_);
     surf_action_->set_activity(this);
     surf_action_->set_category(get_tracing_category());
-    start_time_ = surf_action_->get_start_time();
-    state_ = State::RUNNING;
+    set_start_time(surf_action_->get_start_time());
+    set_state(State::RUNNING);
     on_start(*this);
 
     XBT_DEBUG("Starting communication %p from '%s' to '%s' (surf_action: %p; state: %s)", this, from_->get_cname(),
@@ -322,7 +322,7 @@ CommImpl* CommImpl::start()
     if (surf_action_->get_state() == resource::Action::State::FAILED) {
       XBT_DEBUG("Communication from '%s' to '%s' failed to start because of a link failure", from_->get_cname(),
                 to_->get_cname());
-      state_ = State::LINK_FAILURE;
+      set_state(State::LINK_FAILURE);
       post();
 
     } else if ((src_actor_ != nullptr && src_actor_->is_suspended()) ||
@@ -347,7 +347,7 @@ CommImpl* CommImpl::start()
 
 std::vector<s4u::Link*> CommImpl::get_traversed_links() const
 {
-  xbt_assert(state_ != State::WAITING, "You cannot use %s() if your communication is not ready (%s)", __FUNCTION__,
+  xbt_assert(get_state() != State::WAITING, "You cannot use %s() if your communication is not ready (%s)", __FUNCTION__,
              get_state_str());
   std::vector<s4u::Link*> vlinks;
   XBT_ATTRIB_UNUSED double res = 0;
@@ -390,13 +390,13 @@ void CommImpl::copy_data()
 bool CommImpl::test()
 {
   if ((MC_is_active() || MC_record_replay_is_active()) && src_actor_ && dst_actor_)
-    state_ = State::DONE;
+    set_state(State::DONE);
   return ActivityImpl::test();
 }
 
 void CommImpl::wait_for(actor::ActorImpl* issuer, double timeout)
 {
-  XBT_DEBUG("CommImpl::wait_for(%g), %p, state %s", timeout, this, to_c_str(state_));
+  XBT_DEBUG("CommImpl::wait_for(%g), %p, state %s", timeout, this, get_state_str());
 
   /* Associate this simcall to the wait synchro */
   register_simcall(&issuer->simcall_);
@@ -404,13 +404,13 @@ void CommImpl::wait_for(actor::ActorImpl* issuer, double timeout)
   if (MC_is_active() || MC_record_replay_is_active()) {
     int idx = issuer->simcall_.mc_value_;
     if (idx == 0) {
-      state_ = State::DONE;
+      set_state(State::DONE);
     } else {
       /* If we reached this point, the wait simcall must have a timeout */
       /* Otherwise it shouldn't be enabled and executed by the MC */
       if (timeout < 0.0)
         THROW_IMPOSSIBLE;
-      state_ = (issuer == src_actor_ ? State::SRC_TIMEOUT : State::DST_TIMEOUT);
+      set_state(issuer == src_actor_ ? State::SRC_TIMEOUT : State::DST_TIMEOUT);
     }
     finish();
     return;
@@ -418,7 +418,7 @@ void CommImpl::wait_for(actor::ActorImpl* issuer, double timeout)
 
   /* If the synchro has already finish perform the error handling, */
   /* otherwise set up a waiting timeout on the right side          */
-  if (state_ != State::WAITING && state_ != State::RUNNING) {
+  if (get_state() != State::WAITING && get_state() != State::RUNNING) {
     finish();
   } else { /* we need a sleep action (even when there is no timeout) to be notified of host failures */
     resource::Action* sleep = issuer->get_host()->get_cpu()->sleep(timeout);
@@ -454,7 +454,7 @@ void CommImpl::wait_any_for(actor::ActorImpl* issuer, const std::vector<CommImpl
     auto* comm = comms[idx];
     comm->simcalls_.push_back(&issuer->simcall_);
     simcall_comm_waitany__set__result(&issuer->simcall_, idx);
-    comm->state_ = State::DONE;
+    comm->set_state(State::DONE);
     comm->finish();
     return;
   }
@@ -478,7 +478,7 @@ void CommImpl::wait_any_for(actor::ActorImpl* issuer, const std::vector<CommImpl
     comm->simcalls_.push_back(&issuer->simcall_);
 
     /* see if the synchro is already finished */
-    if (comm->state_ != State::WAITING && comm->state_ != State::RUNNING) {
+    if (comm->get_state() != State::WAITING && comm->get_state() != State::RUNNING) {
       comm->finish();
       break;
     }
@@ -504,13 +504,13 @@ void CommImpl::resume()
 void CommImpl::cancel()
 {
   /* if the synchro is a waiting state means that it is still in a mbox so remove from it and delete it */
-  if (state_ == State::WAITING) {
+  if (get_state() == State::WAITING) {
     if (not detached_) {
       mbox_->remove(this);
-      state_ = State::CANCELED;
+      set_state(State::CANCELED);
     }
   } else if (not MC_is_active() /* when running the MC there are no surf actions */
-             && not MC_record_replay_is_active() && (state_ == State::READY || state_ == State::RUNNING)) {
+             && not MC_record_replay_is_active() && (get_state() == State::READY || get_state() == State::RUNNING)) {
     surf_action_->cancel();
   }
 }
@@ -537,17 +537,17 @@ void CommImpl::post()
 
   /* Update synchro state */
   if (src_timeout_ && src_timeout_->get_state() == resource::Action::State::FINISHED)
-    state_ = State::SRC_TIMEOUT;
+    set_state(State::SRC_TIMEOUT);
   else if (dst_timeout_ && dst_timeout_->get_state() == resource::Action::State::FINISHED)
-    state_ = State::DST_TIMEOUT;
+    set_state(State::DST_TIMEOUT);
   else if (src_timeout_ && src_timeout_->get_state() == resource::Action::State::FAILED)
-    state_ = State::SRC_HOST_FAILURE;
+    set_state(State::SRC_HOST_FAILURE);
   else if (dst_timeout_ && dst_timeout_->get_state() == resource::Action::State::FAILED)
-    state_ = State::DST_HOST_FAILURE;
+    set_state(State::DST_HOST_FAILURE);
   else if (surf_action_ && surf_action_->get_state() == resource::Action::State::FAILED) {
-    state_ = State::LINK_FAILURE;
+    set_state(State::LINK_FAILURE);
   } else
-    state_ = State::DONE;
+    set_state(State::DONE);
 
   XBT_DEBUG("CommImpl::post(): comm %p, state %s, src_proc %p, dst_proc %p, detached: %d", this, get_state_str(),
             src_actor_.get(), dst_actor_.get(), detached_);
@@ -560,7 +560,7 @@ void CommImpl::post()
 }
 void CommImpl::set_exception(actor::ActorImpl* issuer)
 {
-  switch (state_) {
+  switch (get_state()) {
     case State::FAILED:
       issuer->exception_ = std::make_exception_ptr(NetworkFailureException(XBT_THROW_POINT, "Remote peer failed"));
       break;
@@ -578,7 +578,7 @@ void CommImpl::set_exception(actor::ActorImpl* issuer)
       if (issuer == src_actor_)
         issuer->context_->set_wannadie();
       else {
-        state_             = kernel::activity::State::FAILED;
+        set_state(State::FAILED);
         issuer->exception_ = std::make_exception_ptr(NetworkFailureException(XBT_THROW_POINT, "Remote peer failed"));
       }
       break;
@@ -587,7 +587,7 @@ void CommImpl::set_exception(actor::ActorImpl* issuer)
       if (issuer == dst_actor_)
         issuer->context_->set_wannadie();
       else {
-        state_             = kernel::activity::State::FAILED;
+        set_state(State::FAILED);
         issuer->exception_ = std::make_exception_ptr(NetworkFailureException(XBT_THROW_POINT, "Remote peer failed"));
       }
       break;
@@ -604,7 +604,7 @@ void CommImpl::set_exception(actor::ActorImpl* issuer)
       } else {
         XBT_DEBUG("I'm neither source nor dest");
       }
-      state_ = kernel::activity::State::FAILED;
+      set_state(State::FAILED);
       issuer->throw_exception(std::make_exception_ptr(NetworkFailureException(XBT_THROW_POINT, "Link failure")));
       break;
 
@@ -618,19 +618,19 @@ void CommImpl::set_exception(actor::ActorImpl* issuer)
       break;
 
     default:
-      xbt_assert(state_ == State::DONE, "Internal error in CommImpl::finish(): unexpected synchro state %s",
-                 to_c_str(state_));
+      xbt_assert(get_state() == State::DONE, "Internal error in CommImpl::finish(): unexpected synchro state %s",
+                 get_state_str());
   }
 }
 
 void CommImpl::finish()
 {
-  XBT_DEBUG("CommImpl::finish() in state %s", to_c_str(state_));
+  XBT_DEBUG("CommImpl::finish() in state %s", get_state_str());
   /* If the synchro is still in a rendez-vous point then remove from it */
   if (mbox_)
     mbox_->remove(this);
 
-  if (state_ == State::DONE)
+  if (get_state() == State::DONE)
     copy_data();
 
   while (not simcalls_.empty()) {
index d1d0167..6bfc2b7 100644 (file)
@@ -73,7 +73,7 @@ ExecImpl& ExecImpl::set_bytes_amounts(const std::vector<double>& bytes_amounts)
 
 ExecImpl* ExecImpl::start()
 {
-  state_ = State::RUNNING;
+  set_state(State::RUNNING);
   if (not MC_is_active() && not MC_record_replay_is_active()) {
     if (hosts_.size() == 1) {
       surf_action_ = hosts_.front()->get_cpu()->execution_start(flops_amounts_.front(), bound_);
@@ -85,7 +85,7 @@ ExecImpl* ExecImpl::start()
       surf_action_    = host_model->execute_parallel(hosts_, flops_amounts_.data(), bytes_amounts_.data(), -1);
     }
     surf_action_->set_activity(this);
-    start_time_ = surf_action_->get_start_time();
+    set_start_time(surf_action_->get_start_time());
   }
 
   XBT_DEBUG("Create execute synchro %p: %s", this, get_cname());
@@ -94,14 +94,14 @@ ExecImpl* ExecImpl::start()
 
 double ExecImpl::get_remaining() const
 {
-  if (state_ == State::WAITING || state_ == State::FAILED)
+  if (get_state() == State::WAITING || get_state() == State::FAILED)
     return flops_amounts_.front();
   return ActivityImpl::get_remaining();
 }
 
 double ExecImpl::get_seq_remaining_ratio()
 {
-  if (state_ == State::WAITING)
+  if (get_state() == State::WAITING)
     return 1;
   return (surf_action_ == nullptr) ? 0 : surf_action_->get_remains() / surf_action_->get_cost();
 }
@@ -109,7 +109,7 @@ double ExecImpl::get_seq_remaining_ratio()
 double ExecImpl::get_par_remaining_ratio()
 {
   // parallel task: their remain is already between 0 and 1
-  if (state_ == State::WAITING)
+  if (get_state() == State::WAITING)
     return 1;
   return (surf_action_ == nullptr) ? 0 : surf_action_->get_remains();
 }
@@ -139,19 +139,19 @@ void ExecImpl::post()
   if (std::any_of(hosts_.begin(), hosts_.end(), [](const s4u::Host* host) { return not host->is_on(); })) {
     /* If one of the hosts running the synchro failed, notice it. This way, the asking
      * process can be killed if it runs on that host itself */
-    state_ = State::FAILED;
+    set_state(State::FAILED);
   } else if (surf_action_->get_state() == resource::Action::State::FAILED) {
     /* If all the hosts are running the synchro didn't fail, then the synchro was canceled */
-    state_ = State::CANCELED;
+    set_state(State::CANCELED);
   } else if (timeout_detector_ && timeout_detector_->get_state() == resource::Action::State::FINISHED) {
     if (surf_action_->get_remains() > 0.0) {
       surf_action_->set_state(resource::Action::State::FAILED);
-      state_ = State::TIMEOUT;
+      set_state(State::TIMEOUT);
     } else {
-      state_ = State::DONE;
+      set_state(State::DONE);
     }
   } else {
-    state_ = State::DONE;
+    set_state(State::DONE);
   }
 
   clean_action();
@@ -159,7 +159,7 @@ void ExecImpl::post()
   if (get_actor() != nullptr) {
     get_actor()->activities_.remove(this);
   }
-  if (state_ != State::FAILED && cb_id_ >= 0)
+  if (get_state() != State::FAILED && cb_id_ >= 0)
     s4u::Host::on_state_change.disconnect(cb_id_);
   /* Answer all simcalls associated with the synchro */
   finish();
@@ -167,7 +167,7 @@ void ExecImpl::post()
 
 void ExecImpl::set_exception(actor::ActorImpl* issuer)
 {
-  switch (state_) {
+  switch (get_state()) {
     case State::FAILED:
       static_cast<s4u::Exec*>(get_iface())->complete(s4u::Activity::State::FAILED);
       if (issuer->get_host()->is_on())
@@ -185,13 +185,13 @@ void ExecImpl::set_exception(actor::ActorImpl* issuer)
       break;
 
     default:
-      xbt_assert(state_ == State::DONE, "Internal error in ExecImpl::finish(): unexpected synchro state %s",
-                 to_c_str(state_));
+      xbt_assert(get_state() == State::DONE, "Internal error in ExecImpl::finish(): unexpected synchro state %s",
+                 get_state_str());
   }
 }
 void ExecImpl::finish()
 {
-  XBT_DEBUG("ExecImpl::finish() in state %s", to_c_str(state_));
+  XBT_DEBUG("ExecImpl::finish() in state %s", get_state_str());
   while (not simcalls_.empty()) {
     smx_simcall_t simcall = simcalls_.front();
     simcalls_.pop_front();
@@ -236,7 +236,7 @@ void ExecImpl::reset()
   hosts_.clear();
   bytes_amounts_.clear();
   flops_amounts_.clear();
-  start_time_ = -1.0;
+  set_start_time(-1.0);
 }
 
 ActivityImpl* ExecImpl::migrate(s4u::Host* to)
@@ -277,7 +277,7 @@ void ExecImpl::wait_any_for(actor::ActorImpl* issuer, const std::vector<ExecImpl
     /* associate this simcall to the the synchro */
     exec->simcalls_.push_back(&issuer->simcall_);
     /* see if the synchro is already finished */
-    if (exec->state_ != State::WAITING && exec->state_ != State::RUNNING) {
+    if (exec->get_state() != State::WAITING && exec->get_state() != State::RUNNING) {
       exec->finish();
       break;
     }
index 4eaae3b..f2c5bdc 100644 (file)
@@ -74,12 +74,12 @@ IoImpl& IoImpl::set_disk(resource::DiskImpl* disk)
 
 IoImpl* IoImpl::start()
 {
-  state_ = State::RUNNING;
+  set_state(State::RUNNING);
   surf_action_ =
       disk_->get_host()->get_netpoint()->get_englobing_zone()->get_disk_model()->io_start(disk_, size_, type_);
   surf_action_->set_sharing_penalty(sharing_penalty_);
   surf_action_->set_activity(this);
-  start_time_ = surf_action_->get_start_time();
+  set_start_time(surf_action_->get_start_time());
 
   XBT_DEBUG("Create IO synchro %p %s", this, get_cname());
 
@@ -91,18 +91,18 @@ void IoImpl::post()
   performed_ioops_ = surf_action_->get_cost();
   if (surf_action_->get_state() == resource::Action::State::FAILED) {
     if (disk_ && not disk_->is_on())
-      state_ = State::FAILED;
+      set_state(State::FAILED);
     else
-      state_ = State::CANCELED;
+      set_state(State::CANCELED);
   } else if (timeout_detector_ && timeout_detector_->get_state() == resource::Action::State::FINISHED) {
     if (surf_action_->get_remains() > 0.0) {
       surf_action_->set_state(resource::Action::State::FAILED);
-      state_ = State::TIMEOUT;
+      set_state(State::TIMEOUT);
     } else {
-      state_ = State::DONE;
+      set_state(State::DONE);
     }
   } else {
-    state_ = State::DONE;
+    set_state(State::DONE);
   }
 
   clean_action();
@@ -116,7 +116,7 @@ void IoImpl::post()
 }
 void IoImpl::set_exception(actor::ActorImpl* issuer)
 {
-  switch (state_) {
+  switch (get_state()) {
     case State::FAILED:
       issuer->context_->set_wannadie();
       static_cast<s4u::Io*>(get_iface())->complete(s4u::Activity::State::FAILED);
@@ -129,14 +129,14 @@ void IoImpl::set_exception(actor::ActorImpl* issuer)
       issuer->exception_ = std::make_exception_ptr(TimeoutException(XBT_THROW_POINT, "Timeouted"));
       break;
     default:
-      xbt_assert(state_ == State::DONE, "Internal error in IoImpl::finish(): unexpected synchro state %s",
-                 to_c_str(state_));
+      xbt_assert(get_state() == State::DONE, "Internal error in IoImpl::finish(): unexpected synchro state %s",
+                 get_state_str());
   }
 }
 
 void IoImpl::finish()
 {
-  XBT_DEBUG("IoImpl::finish() in state %s", to_c_str(state_));
+  XBT_DEBUG("IoImpl::finish() in state %s", get_state_str());
   while (not simcalls_.empty()) {
     smx_simcall_t simcall = simcalls_.front();
     simcalls_.pop_front();
@@ -192,7 +192,7 @@ void IoImpl::wait_any_for(actor::ActorImpl* issuer, const std::vector<IoImpl*>&
     io->simcalls_.push_back(&issuer->simcall_);
 
     /* see if the synchro is already finished */
-    if (io->state_ != State::WAITING && io->state_ != State::RUNNING) {
+    if (io->get_state() != State::WAITING && io->get_state() != State::RUNNING) {
       io->finish();
       break;
     }
index 68382f1..7a38388 100644 (file)
@@ -40,11 +40,11 @@ void SleepImpl::post()
 {
   if (surf_action_->get_state() == resource::Action::State::FAILED) {
     if (host_ && not host_->is_on())
-      state_ = State::SRC_HOST_FAILURE;
+      set_state(State::SRC_HOST_FAILURE);
     else
-      state_ = State::CANCELED;
+      set_state(State::CANCELED);
   } else if (surf_action_->get_state() == resource::Action::State::FINISHED) {
-    state_ = State::DONE;
+    set_state(State::DONE);
   }
 
   clean_action();
@@ -57,7 +57,7 @@ void SleepImpl::set_exception(actor::ActorImpl* issuer)
 }
 void SleepImpl::finish()
 {
-  XBT_DEBUG("SleepImpl::finish() in state %s", to_c_str(state_));
+  XBT_DEBUG("SleepImpl::finish() in state %s", get_state_str());
   while (not simcalls_.empty()) {
     const s_smx_simcall* simcall = simcalls_.front();
     simcalls_.pop_front();
index 1c97ef8..60d8f80 100644 (file)
@@ -55,11 +55,10 @@ void RawImpl::cancel()
 
 void RawImpl::post()
 {
-  if (surf_action_->get_state() == resource::Action::State::FAILED) {
-    state_ = State::FAILED;
-  } else if (surf_action_->get_state() == resource::Action::State::FINISHED) {
-    state_ = State::SRC_TIMEOUT;
-  }
+  if (surf_action_->get_state() == resource::Action::State::FAILED)
+    set_state(State::FAILED);
+  else if (surf_action_->get_state() == resource::Action::State::FINISHED)
+    set_state(State::SRC_TIMEOUT);
 
   clean_action();
   /* Answer all simcalls associated with the synchro */
@@ -67,18 +66,18 @@ void RawImpl::post()
 }
 void RawImpl::set_exception(actor::ActorImpl* issuer)
 {
-  if (state_ == State::FAILED) {
+  if (get_state() == State::FAILED) {
     issuer->context_->set_wannadie();
     issuer->exception_ = std::make_exception_ptr(HostFailureException(XBT_THROW_POINT, "Host failed"));
   } else {
-    xbt_assert(state_ == State::SRC_TIMEOUT, "Internal error in RawImpl::finish() unexpected synchro state %s",
-               to_c_str(state_));
+    xbt_assert(get_state() == State::SRC_TIMEOUT, "Internal error in RawImpl::finish() unexpected synchro state %s",
+               get_state_str());
   }
 }
 
 void RawImpl::finish()
 {
-  XBT_DEBUG("RawImpl::finish() in state %s", to_c_str(state_));
+  XBT_DEBUG("RawImpl::finish() in state %s", get_state_str());
   xbt_assert(simcalls_.size() == 1, "Unexpected number of simcalls waiting: %zu", simcalls_.size());
   smx_simcall_t simcall = simcalls_.front();
   simcalls_.pop_front();
index ef714f9..8fa361d 100644 (file)
@@ -206,7 +206,7 @@ void ActorImpl::exit()
   /* destroy the blocking synchro if any */
   if (waiting_synchro_ != nullptr) {
     waiting_synchro_->cancel();
-    waiting_synchro_->state_ = activity::State::FAILED;
+    waiting_synchro_->set_state(activity::State::FAILED);
 
     activity::ExecImplPtr exec = boost::dynamic_pointer_cast<activity::ExecImpl>(waiting_synchro_);
     activity::CommImplPtr comm = boost::dynamic_pointer_cast<activity::CommImpl>(waiting_synchro_);
index 60eb3fc..4dd3168 100644 (file)
@@ -110,7 +110,8 @@ bool actor_is_enabled(smx_actor_t actor)
           return true;
       }
       /* On the other hand if it hasn't a timeout, check if the comm is ready.*/
-      else if (act->detached() && act->src_actor_ == nullptr && act->state_ == simgrid::kernel::activity::State::READY)
+      else if (act->detached() && act->src_actor_ == nullptr &&
+               act->get_state() == simgrid::kernel::activity::State::READY)
         return (act->dst_actor_ != nullptr);
       return (act->src_actor_ && act->dst_actor_);
     }
index 648df3c..5ec7671 100644 (file)
@@ -129,14 +129,15 @@ void HostLoad::update()
     auto current_iter                      = iter;
     ++iter;
 
-    if (action != nullptr && action->get_finish_time() != now && activity->state_ == kernel::activity::State::RUNNING) {
+    if (action != nullptr && action->get_finish_time() != now &&
+        activity->get_state() == kernel::activity::State::RUNNING) {
       if (remaining_cost_after_last_update == activity_uninitialized_remaining_cost) {
         remaining_cost_after_last_update = action->get_cost();
       }
       double computed_flops_since_last_update = remaining_cost_after_last_update - /*remaining now*/activity->get_remaining();
       computed_flops_                        += computed_flops_since_last_update;
       remaining_cost_after_last_update        = activity->get_remaining();
-    } else if (activity->state_ == kernel::activity::State::DONE) {
+    } else if (activity->get_state() == kernel::activity::State::DONE) {
       computed_flops_ += remaining_cost_after_last_update;
       current_activities.erase(current_iter);
     }
index aed48fd..d3a766b 100644 (file)
@@ -26,7 +26,7 @@ xbt::signal<void(Comm const&)> Comm::on_completion;
 Comm::~Comm()
 {
   if (state_ == State::STARTED && not detached_ &&
-      (pimpl_ == nullptr || pimpl_->state_ == kernel::activity::State::RUNNING)) {
+      (pimpl_ == nullptr || pimpl_->get_state() == kernel::activity::State::RUNNING)) {
     XBT_INFO("Comm %p freed before its completion. Did you forget to detach it? (state: %s)", this, get_state_str());
     if (pimpl_ != nullptr)
       XBT_INFO("pimpl_->state: %s", pimpl_->get_state_str());
@@ -46,7 +46,7 @@ ssize_t Comm::wait_any_for(const std::vector<CommPtr>& comms, double timeout)
     changed_pos = simcall_comm_waitany(rcomms.data(), rcomms.size(), timeout);
   } catch (const NetworkFailureException& e) {
     for (auto c : comms) {
-      if (c->pimpl_->state_ == kernel::activity::State::FAILED) {
+      if (c->pimpl_->get_state() == kernel::activity::State::FAILED) {
         c->complete(State::FAILED);
       }
     }
index 0275568..633284d 100644 (file)
@@ -32,9 +32,9 @@ ExecPtr Exec::init()
 {
   auto pimpl = kernel::activity::ExecImplPtr(new kernel::activity::ExecImpl());
   unsigned int cb_id = Host::on_state_change.connect([pimpl](s4u::Host const& h) {
-    if (not h.is_on() && pimpl->state_ == kernel::activity::State::RUNNING &&
+    if (not h.is_on() && pimpl->get_state() == kernel::activity::State::RUNNING &&
         std::find(pimpl->get_hosts().begin(), pimpl->get_hosts().end(), &h) != pimpl->get_hosts().end()) {
-      pimpl->state_ = kernel::activity::State::FAILED;
+      pimpl->set_state(kernel::activity::State::FAILED);
       pimpl->post();
     }
   });
index 7402e7f..eda04e7 100644 (file)
@@ -58,10 +58,10 @@ bool Mailbox::ready() const
 {
   bool comm_ready = false;
   if (not pimpl_->empty()) {
-    comm_ready = pimpl_->front()->state_ == kernel::activity::State::DONE;
+    comm_ready = pimpl_->front()->get_state() == kernel::activity::State::DONE;
 
   } else if (pimpl_->is_permanent() && pimpl_->has_some_done_comm()) {
-    comm_ready = pimpl_->done_front()->state_ == kernel::activity::State::DONE;
+    comm_ready = pimpl_->done_front()->get_state() == kernel::activity::State::DONE;
   }
   return comm_ready;
 }
index c9c12bf..9dabe15 100644 (file)
@@ -105,7 +105,7 @@ void HostImpl::turn_off(const actor::ActorImpl* issuer)
       auto hosts = exec->get_hosts();
       if (std::find(hosts.begin(), hosts.end(), &piface_) != hosts.end()) {
         exec->cancel();
-        exec->state_ = activity::State::FAILED;
+        exec->set_state(activity::State::FAILED);
       }
     }
   }