X-Git-Url: https://bilbo.iut-bm.univ-fcomte.fr/and/gitweb/loba.git/blobdiff_plain/9f21b5351f943feb1099f387d385c95bdacf6e62..805029acc414ec084affd6d6f2790e1f1fa20017:/process.cpp diff --git a/process.cpp b/process.cpp index 2b1b369..33a993e 100644 --- a/process.cpp +++ b/process.cpp @@ -302,23 +302,31 @@ void process::data_send(neighbor& nb) { 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); - real_load = 0.0; - } else { - load_to_send = nb.get_debt(); - nb.set_debt(0.0); real_load -= load_to_send; + } else { + load_to_send = 0.0; } } 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)