+void process::handle_message(message* msg, msg_host_t from)
+{
+ switch (msg->get_type()) {
+ case message::CTRL: {
+ neighbor* n = rev_neigh[from];
+ n->set_load(msg->get_amount() + n->get_to_send());
+ if (opt::bookkeeping) {
+ double credit = msg->get_credit();
+ expected_load += credit;
+ n->set_credit(n->get_credit() + credit);
+ }
+ break;
+ }
+ case message::DATA: {
+ neighbor* n = rev_neigh[from];
+ double ld = msg->get_amount();
+ received_load += ld;
+ n->set_credit(n->get_credit() - ld);
+ break;
+ }
+ case message::CTRL_CLOSE:
+ ctrl_close_pending--;
+ close_received = true;
+ break;
+ case message::DATA_CLOSE:
+ data_close_pending--;
+ close_received = true;
+ break;
+ }
+ delete msg;
+}
+
+#define print_loads_generic(vec, verbose, logp, cat) \
+ if (_XBT_LOG_ISENABLEDV((*cat), logp)) { \
+ using std::placeholders::_1; \
+ XBT_XCLOG(cat, logp, "My load: %g (real); %g (expected). " \
+ "Neighbor loads:", real_load, expected_load); \
+ std::for_each(vec.begin(), vec.end(), \
+ std::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
+