Logo AND Algorithmique Numérique Distribuée

Public GIT Repository
factorize code between SIMIX_execution_start and SIMIX_execution_parallel_start
[simgrid.git] / src / kernel / activity / ExecImpl.cpp
index 521785dcc1f3faf3967e1e661cec9b5c30e7793c..259d5cbde872951178e46563581969ac199af9bf 100644 (file)
 
 XBT_LOG_EXTERNAL_DEFAULT_CATEGORY(simix_process);
 
-simgrid::kernel::activity::ExecImpl::ExecImpl(const char* name, sg_host_t host) : host_(host)
+simgrid::kernel::activity::ExecImpl::ExecImpl(const char* name, resource::Action* surf_action,
+                                              resource::Action* timeout_detector, s4u::Host* host)
+    : host_(host)
 {
   if (name)
     this->name = name;
   this->state  = SIMIX_RUNNING;
+
+  surfAction_ = surf_action;
+  surfAction_->set_data(this);
+  if (timeout_detector != nullptr) {
+    timeout_detector->set_data(this);
+    timeoutDetector = timeout_detector;
+  }
+
   XBT_DEBUG("Create exec %p", this);
 }
 
@@ -46,7 +56,7 @@ void simgrid::kernel::activity::ExecImpl::resume()
     surfAction_->resume();
 }
 
-double simgrid::kernel::activity::ExecImpl::remains()
+double simgrid::kernel::activity::ExecImpl::get_remaining()
 {
   xbt_assert(host_ != nullptr, "Calling remains() on a parallel execution is not allowed. "
                                "We would need to return a vector instead of a scalar. "
@@ -55,7 +65,7 @@ double simgrid::kernel::activity::ExecImpl::remains()
   return surfAction_ ? surfAction_->get_remains() : 0;
 }
 
-double simgrid::kernel::activity::ExecImpl::remainingRatio()
+double simgrid::kernel::activity::ExecImpl::get_remaining_ratio()
 {
   if (host_ == nullptr) // parallel task: their remain is already between 0 and 1 (see comment in ExecImpl::remains())
     return surfAction_->get_remains();
@@ -63,7 +73,7 @@ double simgrid::kernel::activity::ExecImpl::remainingRatio()
     return surfAction_->get_remains() / surfAction_->get_cost();
 }
 
-void simgrid::kernel::activity::ExecImpl::setBound(double bound)
+void simgrid::kernel::activity::ExecImpl::set_bound(double bound)
 {
   if (surfAction_)
     surfAction_->set_bound(bound);
@@ -75,7 +85,7 @@ void simgrid::kernel::activity::ExecImpl::post()
                                  /* If the host running the synchro failed, notice it. This way, the asking
                                   * process can be killed if it runs on that host itself */
     state = SIMIX_FAILED;
-  } else if (surfAction_->get_state() == simgrid::kernel::resource::Action::State::failed) {
+  } else if (surfAction_ && surfAction_->get_state() == simgrid::kernel::resource::Action::State::failed) {
     /* If the host running the synchro didn't fail, then the synchro was canceled */
     state = SIMIX_CANCELED;
   } else if (timeoutDetector && timeoutDetector->get_state() == simgrid::kernel::resource::Action::State::done) {