Logo AND Algorithmique Numérique Distribuée

Public GIT Repository
Factorize common code to cancel actions when a resource is turned off.
[simgrid.git] / src / kernel / resource / models / cpu_cas01.cpp
index cb8a40d..35af6fa 100644 (file)
@@ -6,12 +6,12 @@
 #include <simgrid/kernel/routing/NetZoneImpl.hpp>
 #include <simgrid/s4u/Engine.hpp>
 
-#include "simgrid/sg_config.hpp"
 #include "src/kernel/EngineImpl.hpp"
 #include "src/kernel/resource/models/cpu_cas01.hpp"
 #include "src/kernel/resource/models/cpu_ti.hpp"
 #include "src/kernel/resource/profile/Event.hpp"
 #include "src/simgrid/module.hpp"
+#include "src/simgrid/sg_config.hpp"
 
 XBT_LOG_NEW_DEFAULT_SUBCATEGORY(cpu_cas, res_cpu, "CPU resource, CAS01 model (used by default)");
 
@@ -113,20 +113,8 @@ void CpuCas01::apply_event(profile::Event* event, double value)
         get_iface()->turn_on();
       }
     } else {
-      const lmm::Element* elem = nullptr;
-      double date              = EngineImpl::get_clock();
-
       get_iface()->turn_off();
-
-      while (const auto* var = get_constraint()->get_variable(&elem)) {
-        Action* action = var->get_id();
-
-        if (action->get_state() == Action::State::INITED || action->get_state() == Action::State::STARTED ||
-            action->get_state() == Action::State::IGNORED) {
-          action->set_finish_time(date);
-          action->set_state(Action::State::FAILED);
-        }
-      }
+      cancel_actions();
     }
     unref_state_event();