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

Private GIT Repository
Wip++...
[loba.git] / process.cpp
index 4ee3647d6895c4eef6586f92f29ffc498b45b14e..b30fab4b0a9d8a43838e1d346bade1e06baa64f8 100644 (file)
@@ -54,6 +54,8 @@ int process::run()
      *    compute load balancing;
      *    send tasks to neighbors;
      * }
+     * finalize;
+     * wait for pending messages;
      */
 
     /* Open Questions :
@@ -69,24 +71,22 @@ int process::run()
 
 void process::receive()
 {
-    bool received;
-    do {
-        double amount;
-        m_host_t from;
-        received = false;
-        if (comm.recv_info(amount, from)) {
+    message* msg;
+    m_host_t from;
+    while (comm.recv(msg, from)) {
+        switch (msg->get_type()) {
+        case message::INFO:
             // fixme: update neighbor
-            received = true;
+            break;
+        case message::CREDIT:
+            expected_load += msg->get_amount();
+            break;
+        case message::LOAD:
+            load += msg->get_amount();
+            break;
         }
-        if (comm.recv_credit(amount, from)) {
-            expected_load += amount;
-            received = true;
-        }
-        if (comm.recv_load(amount, from)) {
-            load += amount;
-            received = true;
-        }
-    } while (received);
+        delete msg;
+    }
 }
 
 void process::compute()
@@ -98,6 +98,11 @@ void process::compute()
     MSG_task_destroy(task);
 }
 
+void process::finalize()
+{
+    // fixme
+}
+
 void process::print_loads(e_xbt_log_priority_t logp)
 {
     if (!LOG_ISENABLED(logp))