From: Frederic Suter Date: Mon, 16 Dec 2019 09:54:53 +0000 (+0100) Subject: cosmetics in kernel/resource X-Git-Tag: v3.25~272 X-Git-Url: http://info.iut-bm.univ-fcomte.fr/pub/gitweb/simgrid.git/commitdiff_plain/122ace8270460324eaa28fd429cc3f59e621f292 cosmetics in kernel/resource --- diff --git a/include/simgrid/kernel/resource/Action.hpp b/include/simgrid/kernel/resource/Action.hpp index 00ae0df8de..6900b01fce 100644 --- a/include/simgrid/kernel/resource/Action.hpp +++ b/include/simgrid/kernel/resource/Action.hpp @@ -20,12 +20,12 @@ namespace simgrid { namespace kernel { namespace resource { -typedef std::pair heap_element_type; +typedef std::pair heap_element_type; typedef boost::heap::pairing_heap, boost::heap::stable, boost::heap::compare>> heap_type; -typedef std::pair heap_element_type; +typedef std::pair heap_element_type; class XBT_PUBLIC ActionHeap : public heap_type { friend Action; @@ -221,14 +221,14 @@ private: std::string category_; /**< tracing category for categorized resource utilization monitoring */ double cost_; - simgrid::kernel::resource::Model* model_; + Model* model_; void* data_ = nullptr; /**< for your convenience */ activity::ActivityImpl* activity_ = nullptr; /* LMM */ - double last_update_ = 0; - double last_value_ = 0; - kernel::lmm::Variable* variable_ = nullptr; + double last_update_ = 0; + double last_value_ = 0; + lmm::Variable* variable_ = nullptr; ActionHeap::Type type_ = ActionHeap::Type::unset; boost::optional heap_hook_ = boost::none; diff --git a/include/simgrid/kernel/resource/Model.hpp b/include/simgrid/kernel/resource/Model.hpp index ee23a153de..e7578ea724 100644 --- a/include/simgrid/kernel/resource/Model.hpp +++ b/include/simgrid/kernel/resource/Model.hpp @@ -32,7 +32,7 @@ public: Model(const Model&) = delete; Model& operator=(const Model&) = delete; - virtual ~Model(); + virtual ~Model() = default; /** @brief Get the set of [actions](@ref Action) in *inited* state */ Action::StateSet* get_inited_action_set() { return &inited_action_set_; } diff --git a/include/simgrid/kernel/resource/Resource.hpp b/include/simgrid/kernel/resource/Resource.hpp index 9f2c97b720..116705a207 100644 --- a/include/simgrid/kernel/resource/Resource.hpp +++ b/include/simgrid/kernel/resource/Resource.hpp @@ -22,6 +22,19 @@ namespace resource { * @details This is the ancestor class of every resources in SimGrid, such as links, CPU or storage */ class XBT_PUBLIC Resource { + std::string name_; + Model* model_; + bool is_on_ = true; + + lmm::Constraint* const constraint_; + +protected: + struct Metric { + double peak; /**< The peak of the metric, ie its max value */ + 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 */ + }; + public: /** * @brief Constructor of LMM Resources @@ -35,7 +48,7 @@ public: { } - virtual ~Resource(); + virtual ~Resource() = default; /** @brief Get the Model of the current Resource */ Model* get_model() const { return model_; } @@ -67,27 +80,10 @@ public: /** @brief setup the profile file with states events (ON or OFF). The profile must contain boolean values. */ virtual void set_state_profile(profile::Profile* profile); -private: - std::string name_; - Model* model_; - bool is_on_ = true; - -public: /* LMM */ /** @brief Get the lmm constraint associated to this Resource if it is part of a LMM component (or null if none) */ lmm::Constraint* get_constraint() const { return constraint_; } -private: - kernel::lmm::Constraint* const constraint_; - -public: profile::Event* state_event_ = nullptr; - -protected: - struct Metric { - double peak; /**< The peak of the metric, ie its max value */ - 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 */ - }; }; } // namespace resource } // namespace kernel diff --git a/src/kernel/resource/Action.cpp b/src/kernel/resource/Action.cpp index a74efb5b1f..b258eadbbe 100644 --- a/src/kernel/resource/Action.cpp +++ b/src/kernel/resource/Action.cpp @@ -137,7 +137,7 @@ void Action::cancel() set_state(Action::State::FAILED); if (get_model()->get_update_algorithm() == Model::UpdateAlgo::LAZY) { if (modified_set_hook_.is_linked()) - simgrid::xbt::intrusive_erase(*get_model()->get_modified_set(), *this); + xbt::intrusive_erase(*get_model()->get_modified_set(), *this); get_model()->get_action_heap().remove(this); } } @@ -196,6 +196,7 @@ void Action::update_max_duration(double delta) if (max_duration_ != NO_MAX_DURATION) double_update(&max_duration_, delta, sg_surf_precision); } + void Action::update_remains(double delta) { double_update(&remains_, delta, sg_maxmin_precision * sg_surf_precision); @@ -210,11 +211,13 @@ double ActionHeap::top_date() const { return top().first; } + void ActionHeap::insert(Action* action, double date, ActionHeap::Type type) { action->type_ = type; action->heap_hook_ = emplace(std::make_pair(date, action)); } + void ActionHeap::remove(Action* action) { action->type_ = ActionHeap::Type::unset; @@ -223,6 +226,7 @@ void ActionHeap::remove(Action* action) action->heap_hook_ = boost::none; } } + void ActionHeap::update(Action* action, double date, ActionHeap::Type type) { action->type_ = type; @@ -232,6 +236,7 @@ void ActionHeap::update(Action* action, double date, ActionHeap::Type type) action->heap_hook_ = emplace(std::make_pair(date, action)); } } + Action* ActionHeap::pop() { Action* action = top().second; diff --git a/src/kernel/resource/Model.cpp b/src/kernel/resource/Model.cpp index 43577140af..b95f61f3eb 100644 --- a/src/kernel/resource/Model.cpp +++ b/src/kernel/resource/Model.cpp @@ -13,7 +13,6 @@ namespace kernel { namespace resource { Model::Model(Model::UpdateAlgo algo) : update_algorithm_(algo) {} -Model::~Model() = default; Action::ModifiedSet* Model::get_modified_set() const { @@ -143,7 +142,7 @@ Action* Model::extract_action(Action::StateSet* list) { if (list->empty()) return nullptr; - simgrid::kernel::resource::Action* res = &list->front(); + Action* res = &list->front(); list->pop_front(); return res; } diff --git a/src/kernel/resource/Resource.cpp b/src/kernel/resource/Resource.cpp index a8e7f5d7e4..64c7bae759 100644 --- a/src/kernel/resource/Resource.cpp +++ b/src/kernel/resource/Resource.cpp @@ -13,8 +13,6 @@ namespace simgrid { namespace kernel { namespace resource { -Resource::~Resource() = default; - double Resource::get_load() const { return constraint_->get_usage();