Logo AND Algorithmique Numérique Distribuée

Public GIT Repository
cosmetics in kernel/resource
authorFrederic Suter <frederic.suter@cc.in2p3.fr>
Mon, 16 Dec 2019 09:54:53 +0000 (10:54 +0100)
committerFrederic Suter <frederic.suter@cc.in2p3.fr>
Mon, 16 Dec 2019 12:43:56 +0000 (13:43 +0100)
include/simgrid/kernel/resource/Action.hpp
include/simgrid/kernel/resource/Model.hpp
include/simgrid/kernel/resource/Resource.hpp
src/kernel/resource/Action.cpp
src/kernel/resource/Model.cpp
src/kernel/resource/Resource.cpp

index 00ae0df..6900b01 100644 (file)
@@ -20,12 +20,12 @@ namespace simgrid {
 namespace kernel {
 namespace resource {
 
-typedef std::pair<double, simgrid::kernel::resource::Action*> heap_element_type;
+typedef std::pair<double, Action*> heap_element_type;
 typedef boost::heap::pairing_heap<heap_element_type, boost::heap::constant_time_size<false>, boost::heap::stable<true>,
                                   boost::heap::compare<simgrid::xbt::HeapComparator<heap_element_type>>>
     heap_type;
 
-typedef std::pair<double, simgrid::kernel::resource::Action*> heap_element_type;
+typedef std::pair<double, Action*> 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<ActionHeap::handle_type> heap_hook_ = boost::none;
index ee23a15..e7578ea 100644 (file)
@@ -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_; }
index 9f2c97b..116705a 100644 (file)
@@ -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
index a74efb5..b258ead 100644 (file)
@@ -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;
index 4357714..b95f61f 100644 (file)
@@ -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;
 }
index a8e7f5d..64c7bae 100644 (file)
@@ -13,8 +13,6 @@ namespace simgrid {
 namespace kernel {
 namespace resource {
 
-Resource::~Resource() = default;
-
 double Resource::get_load() const
 {
   return constraint_->get_usage();