Logo AND Algorithmique Numérique Distribuée

Public GIT Repository
[sonar] Constify pointer and reference parameters in src/smpi/.
[simgrid.git] / src / smpi / plugins / load_balancer / load_balancer.hpp
index 2d1ec8d..3c87f07 100644 (file)
@@ -1,4 +1,4 @@
-/* Copyright (c) 2006-2018. The SimGrid Team. All rights reserved.          */
+/* Copyright (c) 2006-2019. The SimGrid Team. All rights reserved.          */
 
 /* This program is free software; you can redistribute it and/or modify it
  * under the terms of the license (GNU LGPL) which comes with this package. */
@@ -14,8 +14,6 @@ namespace loadbalancer {
 
 class XBT_PRIVATE Mapping {
 public:
-  Mapping() = default;
-  ~Mapping() = default;
   /** Each host can have an arbitrary number of actors -> multimap **/
   typedef std::unordered_multimap<simgrid::s4u::Host*, simgrid::s4u::ActorPtr> host_to_actors_map_t;
   host_to_actors_map_t host_to_actors;
@@ -45,14 +43,11 @@ public:
     return host_to_actors.count(host); // TODO This is linear in the size of the map. Maybe replace by constant lookup through another map?
   }
 
-  void for_each_actor(simgrid::s4u::Host* host, std::function<void(simgrid::s4u::ActorPtr)> callback)
+  void for_each_actor(simgrid::s4u::Host* host, const std::function<void(simgrid::s4u::ActorPtr)>& callback)
   {
     auto range = host_to_actors.equal_range(host);
-    std::for_each(
-        range.first,
-        range.second,
-        [&callback](host_to_actors_map_t::value_type& x) { callback(x.second); }
-    );
+    std::for_each(range.first, range.second,
+                  [&callback](host_to_actors_map_t::value_type const& x) { callback(x.second); });
   }
 };
 
@@ -62,8 +57,6 @@ class XBT_PRIVATE LoadBalancer
   std::map</*proc id*/int, double> actor_computation;
 
 public:
-  LoadBalancer();
-  ~LoadBalancer();
   void run();
   void assign(simgrid::s4u::ActorPtr actor, simgrid::s4u::Host* host);
   
@@ -71,7 +64,7 @@ public:
    * FIXME These are functions used for testing and should be re-written or removed
    */
   simgrid::s4u::Host* get_mapping(simgrid::s4u::ActorPtr);
-  void record_actor_computation(simgrid::s4u::ActorPtr actor, double load);
+  void record_actor_computation(simgrid::s4u::Actor const& actor, double load);
 };
 
 }