Logo AND Algorithmique Numérique Distribuée

Public GIT Repository
make more ActivityImpl fields private
[simgrid.git] / src / kernel / activity / ExecImpl.cpp
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;
     }