]> AND Private Git Repository - loba.git/commitdiff
Logo AND Algorithmique Numérique Distribuée

Private GIT Repository
Reintroduce process::get_sum_of_to_send().
authorArnaud Giersch <arnaud.giersch@iut-bm.univ-fcomte.fr>
Fri, 18 Feb 2011 07:12:47 +0000 (08:12 +0100)
committerArnaud Giersch <arnaud.giersch@iut-bm.univ-fcomte.fr>
Fri, 18 Feb 2011 07:12:47 +0000 (08:12 +0100)
process.cpp
process.h

index 470ad41bad93f4ee9b199d9ec1ffefb909228f0b..8e9f5245fd896a8cd9cfcff05ff51a53b3235c48 100644 (file)
@@ -1,6 +1,7 @@
 #include <algorithm>
 #include <tr1/functional>
 #include <iterator>
+#include <numeric>
 #include <stdexcept>
 #include <sstream>
 #include <xbt/log.h>
@@ -252,6 +253,17 @@ bool process::still_running()
     return last_status;
 }
 
+double process::get_sum_of_to_send() const
+{
+    using std::tr1::bind;
+    using std::tr1::placeholders::_1;
+    using std::tr1::placeholders::_2;
+
+    return std::accumulate(neigh.begin(), neigh.end(), 0.0,
+                           bind(std::plus<double>(),
+                                _1, bind(&neighbor::get_to_send, _2)));
+}
+
 void process::load_balance()
 {
     if (lb_iter == 1)           // warn only once
index 3e912f03c68186a860f3a16116f74018c93c7d06..926bf1f9d064e343cd87273bdbdec41f41879cf9 100644 (file)
--- a/process.h
+++ b/process.h
@@ -110,6 +110,9 @@ private:
 
     bool still_running();
 
+    // Returns the sum of "to_send" for all neighbors.
+    double get_sum_of_to_send() const;
+
     // Send procedures
     void ctrl_send(neighbor& nb);
     void data_send(neighbor& nb);