- if (opt::exit_on_close && close_received)
- one_more = false;
- else if (opt::maxiter && iter >= opt::maxiter)
- one_more = false;
-
- } while (one_more && may_receive && load == 0 && !NDS);
- DEBUG0("RECEIVE LOOP ENDED");
-#undef NDS
+ // fixme: this check should be implemented with a distributed
+ // algorithm, and not a shared global variable!
+ // fixme: should this chunk be moved before call to receive() ?
+ if (100.0 * total_load_running / total_load_init <=
+ opt::load_ratio_threshold) {
+ VERB0("No more load to balance in system, stopping.");
+ break;
+ }