X-Git-Url: http://info.iut-bm.univ-fcomte.fr/pub/gitweb/simgrid.git/blobdiff_plain/fa4076fe495b91c58d1f6a3cdbbb3cb95b39a4bd..66f84edf2502421941eaaa74414323a16979b9ad:/include/simgrid/kernel/resource/Resource.hpp diff --git a/include/simgrid/kernel/resource/Resource.hpp b/include/simgrid/kernel/resource/Resource.hpp index 2c1bcc1014..fce350f6df 100644 --- a/include/simgrid/kernel/resource/Resource.hpp +++ b/include/simgrid/kernel/resource/Resource.hpp @@ -7,6 +7,7 @@ #define SIMGRID_KERNEL_RESOURCE_RESOURCE_HPP #include "src/kernel/lmm/maxmin.hpp" // Constraint +#include "src/kernel/resource/profile/Event.hpp" #include "src/kernel/resource/profile/FutureEvtSet.hpp" #include "src/kernel/resource/profile/Profile.hpp" #include @@ -28,6 +29,7 @@ class XBT_PUBLIC Resource { std::string name_ = "unnamed"; bool is_on_ = true; bool sealed_ = false; + profile::Event* state_event_ = nullptr; protected: struct Metric { @@ -35,7 +37,10 @@ protected: double scale; /**< Current availability of the metric according to the profiles, in [0,1] */ profile::Event* event; /**< The associated profile event associated to the metric */ }; - profile::Event* state_event_ = nullptr; + + virtual profile::Event* get_state_event() const { return state_event_; } + virtual void set_state_event(profile::Event* evt) { state_event_ = evt; } + virtual void unref_state_event() { tmgr_trace_event_unref(&state_event_); } public: explicit Resource(const std::string& name) : name_(name){}; @@ -74,8 +79,8 @@ public: AnyResource* set_state_profile(profile::Profile* profile) { if (profile) { - xbt_assert(state_event_ == nullptr, "Cannot set a second state profile to %s", get_cname()); - state_event_ = profile->schedule(&profile::future_evt_set, this); + xbt_assert(get_state_event() == nullptr, "Cannot set a second state profile to %s", get_cname()); + set_state_event(profile->schedule(&profile::future_evt_set, this)); } return static_cast(this);