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

Private GIT Repository
Add options to control min./max. data transfer amount.
[loba.git] / process.cpp
index 2b1b36936b0dba553cdf7460082b546befe9e0d6..33a993ef5eb8e96041302b563acef1fafeb557b7 100644 (file)
@@ -302,23 +302,31 @@ void process::data_send(neighbor& nb)
 {
     double load_to_send;
     if (opt::bookkeeping) {
 {
     double load_to_send;
     if (opt::bookkeeping) {
-        if (real_load <= nb.get_debt()) {
-            load_to_send = real_load;
+        load_to_send = std::min(real_load, nb.get_debt());
+        if (load_to_send >= opt::min_transfer_amount) {
             nb.set_debt(nb.get_debt() - load_to_send);
             nb.set_debt(nb.get_debt() - load_to_send);
-            real_load = 0.0;
-        } else {
-            load_to_send = nb.get_debt();
-            nb.set_debt(0.0);
             real_load -= load_to_send;
             real_load -= load_to_send;
+        } else {
+            load_to_send = 0.0;
         }
     } else {
         load_to_send = nb.get_to_send();
         }
     } else {
         load_to_send = nb.get_to_send();
-        nb.set_to_send(0.0);
-        real_load -= load_to_send;
+        if (load_to_send >= opt::min_transfer_amount) {
+            nb.set_to_send(0.0);
+            real_load -= load_to_send;
+        } else {
+            load_to_send = 0.0;
+        }
+    }
+    while (load_to_send > 0.0) {
+        double amount;
+        if (opt::max_transfer_amount)
+            amount = std::min(load_to_send, opt::max_transfer_amount);
+        else
+            amount = load_to_send;
+        comm.data_send(nb.get_data_mbox(), new message(message::LOAD, amount));
+        load_to_send -= amount;
     }
     }
-    if (load_to_send > 0.0)
-        comm.data_send(nb.get_data_mbox(),
-                       new message(message::LOAD, load_to_send));
 }
 
 void process::ctrl_close(neighbor& nb)
 }
 
 void process::ctrl_close(neighbor& nb)