+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);
+}
+
+void process::print_loads_p(bool verbose,
+ e_xbt_log_priority_t logp,
+ xbt_log_category_t cat) const
+{
+ print_loads_generic(pneigh, verbose, logp, cat);
+}
+
+#undef print_loads_generic
+
+void process::ctrl_send(neighbor& nb)
+{
+ double info_to_send = get_load();
+ if (info_to_send != prev_load_broadcast)
+ comm.ctrl_send(nb.get_ctrl_mbox(),
+ new message(message::INFO, info_to_send));
+ if (opt::bookkeeping) {
+ double debt_to_send = nb.get_to_send();
+ if (debt_to_send > 0.0) {
+ nb.set_to_send(0.0);
+ nb.set_debt(nb.get_debt() + debt_to_send);
+ comm.ctrl_send(nb.get_ctrl_mbox(),
+ new message(message::CREDIT, debt_to_send));
+ }
+ }
+}
+
+void process::data_send(neighbor& nb)
+{
+ double load_to_send;
+ if (opt::bookkeeping) {
+ if (real_load <= nb.get_debt()) {
+ load_to_send = real_load;
+ 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;
+ }