- if (expected_load != prev_load_broadcast)
- comm.send(nb.get_ctrl_mbox(),
- new message(message::INFO, expected_load));
- double load_to_send;
- double new_debt;
- double debt_to_send = nb.get_to_send();
- if (debt_to_send > 0.0) {
- comm.send(nb.get_ctrl_mbox(),
- new message(message::CREDIT, debt_to_send));
- nb.set_to_send(0.0);
- new_debt = nb.get_debt() + debt_to_send;
- } else {
- new_debt = nb.get_debt();
- }
- if (load <= new_debt) {
- load_to_send = load;
- nb.set_debt(new_debt - load_to_send);
- load = 0.0;
- } else {
- load_to_send = new_debt;
- nb.set_debt(0.0);
- load -= load_to_send;
- }
- if (load_to_send > 0.0)
- comm.send(nb.get_data_mbox(), new message(message::LOAD, load_to_send));
+ if (lb_iter == 1) // warn only once
+ XBT_WARN("process::load_balance() is a no-op!");
+}
+
+void process::send(neighbor& nb, double amount)
+{
+ set_load(get_load() - amount);
+ nb.set_to_send(nb.get_to_send() + amount);
+ nb.set_load(nb.get_load() + amount);
+}
+
+#define print_loads_generic(vec, verbose, logp, cat) \
+ if (_XBT_LOG_ISENABLEDV((*cat), logp)) { \
+ using std::tr1::bind; \
+ using std::tr1::placeholders::_1; \
+ XBT_XCLOG(cat, logp, "Neighbor loads:"); \
+ std::for_each(vec.begin(), vec.end(), \
+ bind(&neighbor::print, _1, verbose, logp, cat)); \
+ } else ((void)0)
+
+void process::print_loads(bool verbose,
+ e_xbt_log_priority_t logp,
+ xbt_log_category_t cat) const
+{
+ print_loads_generic(neigh, verbose, logp, cat);