X-Git-Url: http://bilbo.iut-bm.univ-fcomte.fr/pub/gitweb/simgrid.git/blobdiff_plain/80b0dab1bd7ba4a54252a45cba41e33991e9f6ff..9abea5188b7bc67c822270a2cb300c777d3b2727:/src/kernel/resource/Resource.hpp diff --git a/src/kernel/resource/Resource.hpp b/src/kernel/resource/Resource.hpp index 6c864e33b9..1ed1e3541c 100644 --- a/src/kernel/resource/Resource.hpp +++ b/src/kernel/resource/Resource.hpp @@ -7,6 +7,7 @@ #define SIMGRID_KERNEL_RESOURCE_RESOURCE_HPP #include "simgrid/forward.h" +#include "src/kernel/EngineImpl.hpp" #include "src/kernel/actor/Simcall.hpp" #include "src/kernel/lmm/maxmin.hpp" // Constraint #include "src/kernel/resource/profile/Event.hpp" @@ -72,6 +73,21 @@ template class Resource_T : public Resource { Model* model_ = nullptr; lmm::Constraint* constraint_ = nullptr; +protected: + void cancel_actions() + { + 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->get_state() == Action::State::IGNORED) { + action->set_finish_time(now); + action->set_state(Action::State::FAILED); + } + } + } + public: using Resource::Resource; /** @brief setup the profile file with states events (ON or OFF). The profile must contain boolean values. */ @@ -115,7 +131,7 @@ public: /** @brief returns the current load due to activities (in flops per second, byte per second or similar) * * The load due to external usages modeled by profile files is ignored.*/ - virtual double get_load() const { return constraint_->get_usage(); } + virtual double get_load() const { return constraint_->get_load(); } bool is_used() const override { return model_->get_maxmin_system()->constraint_used(constraint_); } };