Logo AND Algorithmique Numérique Distribuée

Public GIT Repository
Try to help sonar.
[simgrid.git] / src / surf / network_cm02.cpp
index f5caa3a..2f78a0d 100644 (file)
@@ -172,7 +172,7 @@ void NetworkCm02Model::update_actions_state_lazy(double now, double /*delta*/)
   }
 }
 
-void NetworkCm02Model::update_actions_state_full(double now, double delta)
+void NetworkCm02Model::update_actions_state_full(double /*now*/, double delta)
 {
   for (auto it = std::begin(*get_started_action_set()); it != std::end(*get_started_action_set());) {
     NetworkCm02Action& action = static_cast<NetworkCm02Action&>(*it);
@@ -199,11 +199,11 @@ void NetworkCm02Model::update_actions_state_full(double now, double delta)
     }
     action.update_remains(action.get_variable()->get_value() * delta);
 
-    if (action.get_max_duration() > NO_MAX_DURATION)
+    if (action.get_max_duration() != NO_MAX_DURATION)
       action.update_max_duration(delta);
 
     if (((action.get_remains() <= 0) && (action.get_variable()->get_weight() > 0)) ||
-        ((action.get_max_duration() > NO_MAX_DURATION) && (action.get_max_duration() <= 0))) {
+        ((action.get_max_duration() != NO_MAX_DURATION) && (action.get_max_duration() <= 0))) {
       action.finish(Action::State::FINISHED);
     }
   }
@@ -222,12 +222,13 @@ Action* NetworkCm02Model::communicate(s4u::Host* src, s4u::Host* dst, double siz
              "You're trying to send data from %s to %s but there is no connecting path between these two hosts.",
              src->get_cname(), dst->get_cname());
 
-  bool failed = std::any_of(route.begin(), route.end(), [](LinkImpl* link) { return link->is_off(); });
+  bool failed = std::any_of(route.begin(), route.end(), [](const LinkImpl* link) { return not link->is_on(); });
 
   if (cfg_crosstraffic) {
     dst->route_to(src, back_route, nullptr);
     if (not failed)
-      failed = std::any_of(back_route.begin(), back_route.end(), [](LinkImpl* const& link) { return link->is_off(); });
+      failed =
+          std::any_of(back_route.begin(), back_route.end(), [](const LinkImpl* link) { return not link->is_on(); });
   }
 
   NetworkCm02Action *action = new NetworkCm02Action(this, size, failed);
@@ -318,7 +319,7 @@ NetworkCm02Link::NetworkCm02Link(NetworkCm02Model* model, const std::string& nam
   simgrid::s4u::Link::on_creation(this->piface_);
 }
 
-void NetworkCm02Link::apply_event(tmgr_trace_event_t triggered, double value)
+void NetworkCm02Link::apply_event(kernel::profile::Event* triggered, double value)
 {
   /* Find out which of my iterators was triggered, and react accordingly */
   if (triggered == bandwidth_.event) {
@@ -423,7 +424,6 @@ void NetworkCm02Action::update_remains_lazy(double now)
     return;
 
   double delta        = now - get_last_update();
-  double max_duration = get_max_duration();
 
   if (get_remains_no_update() > 0) {
     XBT_DEBUG("Updating action(%p): remains was %f, last_update was: %f", this, get_remains_no_update(),
@@ -433,13 +433,10 @@ void NetworkCm02Action::update_remains_lazy(double now)
     XBT_DEBUG("Updating action(%p): remains is now %f", this, get_remains_no_update());
   }
 
-  if (max_duration > NO_MAX_DURATION) {
-    double_update(&max_duration, delta, sg_surf_precision);
-    set_max_duration(max_duration);
-  }
+  update_max_duration(delta);
 
   if ((get_remains_no_update() <= 0 && (get_variable()->get_weight() > 0)) ||
-      ((max_duration > NO_MAX_DURATION) && (max_duration <= 0))) {
+      ((get_max_duration() != NO_MAX_DURATION) && (get_max_duration() <= 0))) {
     finish(Action::State::FINISHED);
     get_model()->get_action_heap().remove(this);
   }