From: Arnaud Giersch Date: Wed, 19 Jan 2011 10:21:37 +0000 (+0100) Subject: Move sleep between iterations in a better place. X-Git-Tag: v0.1~188^2~27 X-Git-Url: https://bilbo.iut-bm.univ-fcomte.fr/and/gitweb/loba.git/commitdiff_plain/366ebfe19c715dc3773637f786f5a591a6bb8199?ds=inline;hp=-c Move sleep between iterations in a better place. --- 366ebfe19c715dc3773637f786f5a591a6bb8199 diff --git a/process.cpp b/process.cpp index 0f53576..80fd618 100644 --- a/process.cpp +++ b/process.cpp @@ -72,18 +72,13 @@ int process::run() VERB0("Starting..."); comp_iter = lb_iter = 0; while (true) { - if (opt::min_iter_duration) { + double ld = lb_load(); + if (ld > 0.0) { double now = MSG_get_clock(); - if (now < next_iter_after_date){ - double delay = next_iter_after_date - now; - DEBUG1("sleeping for %g s", delay); - MSG_process_sleep(delay); - } + if (now < next_iter_after_date) + MSG_process_sleep(next_iter_after_date - now); next_iter_after_date = MSG_get_clock() + opt::min_iter_duration; - } - double ld = lb_load(); - if (ld > 0.0) { ++lb_iter; if (opt::log_rate && lb_iter % opt::log_rate == 0) {