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

Private GIT Repository
Add load balancing algorithm selection facility.
[loba.git] / process.h
index a49c6efcd41e376189683c7761126db8abe0d859..607a6af130e1dc330f555d4b5b23edc45eea8c24 100644 (file)
--- a/process.h
+++ b/process.h
@@ -1,8 +1,17 @@
 #ifndef PROCESS_H
 #define PROCESS_H
 
 #ifndef PROCESS_H
 #define PROCESS_H
 
-#include <map>
+#define USE_UNORDERED_MAP 1
+//#undef USE_UNORDERED_MAP
+
 #include <vector>
 #include <vector>
+#ifdef USE_UNORDERED_MAP
+#  include <tr1/unordered_map>
+#  define MAP_TEMPLATE std::tr1::unordered_map
+#else
+#  include <map>
+#  define MAP_TEMPLATE std::map
+#endif
 #include <msg/msg.h>
 #include "communicator.h"
 #include "neighbor.h"
 #include <msg/msg.h>
 #include "communicator.h"
 #include "neighbor.h"
 class process {
 public:
     process(int argc, char* argv[]);
 class process {
 public:
     process(int argc, char* argv[]);
-    ~process() { };
+    ~process();
     int run();
 
     int run();
 
+protected:
+    typedef std::vector<neighbor> neigh_type;
+    typedef std::vector<neighbor*> pneigh_type;
+
+    neigh_type neigh;
+    pneigh_type pneigh;
+
 private:
 private:
-    std::vector<neighbor> neigh;
-    std::map<m_host_t, neighbor*> rev_neigh;
+    typedef MAP_TEMPLATE<m_host_t, neighbor*> rev_neigh_type;
+    enum recv_wait_mode { NO_WAIT = 0, WAIT, WAIT_FOR_CLOSE };
+
+    rev_neigh_type rev_neigh;
 
     communicator comm;
     int ctrl_close_pending;
 
     communicator comm;
     int ctrl_close_pending;
@@ -23,20 +41,21 @@ private:
 
     unsigned iter;
 
 
     unsigned iter;
 
+    double prev_load_broadcast;
     double load;
     double expected_load;
 
     double load;
     double expected_load;
 
-    void compute();
+    double sum_of_to_send() const;
     virtual double load_balance(double my_load);
     virtual double load_balance(double my_load);
+
+    void compute();
     void send1_no_bookkeeping(neighbor& nb);
     void send1_bookkeeping(neighbor& nb);
     void send();
     void send1_no_bookkeeping(neighbor& nb);
     void send1_bookkeeping(neighbor& nb);
     void send();
-    bool receive(bool wait_for_close);
+    bool receive(recv_wait_mode wait);
     void finalize1(neighbor& nb);
     void finalize();
     void print_loads(e_xbt_log_priority_t logp = xbt_log_priority_info);
     void finalize1(neighbor& nb);
     void finalize();
     void print_loads(e_xbt_log_priority_t logp = xbt_log_priority_info);
-
-    void insert_neighbor_in_map(neighbor& nb);
 };
 
 #endif // !PROCESS_H
 };
 
 #endif // !PROCESS_H