Logo AND Algorithmique Numérique Distribuée

Public GIT Repository
[sonar] Don't mix public and private data members for ptasks
authorFrederic Suter <frederic.suter@cc.in2p3.fr>
Wed, 8 Jan 2020 12:17:26 +0000 (13:17 +0100)
committerFrederic Suter <frederic.suter@cc.in2p3.fr>
Thu, 9 Jan 2020 08:13:50 +0000 (09:13 +0100)
src/surf/ptask_L07.cpp
src/surf/ptask_L07.hpp

index 4478d5342bee87a6ac2d2918732145c5cbdf2ec4..43591c07b2866d103be5d7eb154c30b9b1628f74 100644 (file)
@@ -71,8 +71,8 @@ double HostL07Model::next_occurring_event(double now)
   double min = HostModel::next_occurring_event_full(now);
   for (kernel::resource::Action const& action : *get_started_action_set()) {
     const L07Action& net_action = static_cast<const L07Action&>(action);
   double min = HostModel::next_occurring_event_full(now);
   for (kernel::resource::Action const& action : *get_started_action_set()) {
     const L07Action& net_action = static_cast<const L07Action&>(action);
-    if (net_action.latency_ > 0 && (min < 0 || net_action.latency_ < min)) {
-      min = net_action.latency_;
+    if (net_action.get_latency() > 0 && (min < 0 || net_action.get_latency() < min)) {
+      min = net_action.get_latency();
       XBT_DEBUG("Updating min with %p (start %f): %f", &net_action, net_action.get_start_time(), min);
     }
   }
       XBT_DEBUG("Updating min with %p (start %f): %f", &net_action, net_action.get_start_time(), min);
     }
   }
@@ -86,13 +86,13 @@ void HostL07Model::update_actions_state(double /*now*/, double delta)
   for (auto it = std::begin(*get_started_action_set()); it != std::end(*get_started_action_set());) {
     L07Action& action = static_cast<L07Action&>(*it);
     ++it; // increment iterator here since the following calls to action.finish() may invalidate it
   for (auto it = std::begin(*get_started_action_set()); it != std::end(*get_started_action_set());) {
     L07Action& action = static_cast<L07Action&>(*it);
     ++it; // increment iterator here since the following calls to action.finish() may invalidate it
-    if (action.latency_ > 0) {
-      if (action.latency_ > delta) {
-        double_update(&(action.latency_), delta, sg_surf_precision);
+    if (action.get_latency() > 0) {
+      if (action.get_latency() > delta) {
+        action.update_latency(delta, sg_surf_precision);
       } else {
       } else {
-        action.latency_ = 0.0;
+        action.set_latency(0.0);
       }
       }
-      if ((action.latency_ <= 0.0) && (action.is_suspended() == 0)) {
+      if ((action.get_latency() <= 0.0) && (action.is_suspended() == 0)) {
         action.updateBound();
         get_maxmin_system()->update_variable_penalty(action.get_variable(), 1.0);
         action.set_last_update();
         action.updateBound();
         get_maxmin_system()->update_variable_penalty(action.get_variable(), 1.0);
         action.set_last_update();
index 4243752b142465858665191c188205f31e972b91..4025beec20e62f78c6260f5488317ab51697aa63 100644 (file)
@@ -112,6 +112,16 @@ public:
  * Action *
  **********/
 class L07Action : public kernel::resource::CpuAction {
  * Action *
  **********/
 class L07Action : public kernel::resource::CpuAction {
+  std::vector<s4u::Host*> hostList_;
+  bool free_arrays_ = false; // By default, computationAmount_ and friends are freed by caller. But not for sequential
+                             // exec and regular comms
+  const double* computationAmount_;   /* pointer to the data that lives in s4u action -- do not free unless if
+                                       * free_arrays */
+  const double* communicationAmount_; /* pointer to the data that lives in s4u action -- do not free unless if
+                                       * free_arrays */
+  double latency_;
+  double rate_;
+
   friend CpuAction* CpuL07::execution_start(double size);
   friend CpuAction* CpuL07::sleep(double duration);
   friend CpuAction* HostL07Model::execute_parallel(const std::vector<s4u::Host*>& host_list, const double* flops_amount,
   friend CpuAction* CpuL07::execution_start(double size);
   friend CpuAction* CpuL07::sleep(double duration);
   friend CpuAction* HostL07Model::execute_parallel(const std::vector<s4u::Host*>& host_list, const double* flops_amount,
@@ -126,18 +136,9 @@ public:
   ~L07Action();
 
   void updateBound();
   ~L07Action();
 
   void updateBound();
-
-  std::vector<s4u::Host*> hostList_;
-  const double* computationAmount_;   /* pointer to the data that lives in s4u action -- do not free unless if
-                                       * free_arrays */
-  const double* communicationAmount_; /* pointer to the data that lives in s4u action -- do not free unless if
-                                       * free_arrays */
-  double latency_;
-  double rate_;
-
-private:
-  bool free_arrays_ = false; // By default, computationAmount_ and friends are freed by caller. But not for sequential
-                             // exec and regular comms
+  double get_latency() const { return latency_; }
+  void set_latency(double latency) { latency_ = latency; }
+  void update_latency(double delta, double precision) { double_update(&latency_, delta, precision); }
 };
 
 } // namespace surf
 };
 
 } // namespace surf