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 / DiskImpl.cpp
index a231432..20c23ac 100644 (file)
@@ -71,16 +71,7 @@ void DiskImpl::turn_off()
     Resource::turn_off();
     s4u::Disk::on_onoff(piface_);
     piface_.on_this_onoff(piface_);
-
-    const kernel::lmm::Element* elem = nullptr;
-    double now                       = EngineImpl::get_clock();
-    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->set_finish_time(now);
-        action->set_state(Action::State::FAILED);
-      }
-    }
+    cancel_actions();
   }
 }