]> AND Private Git Repository - loba.git/blobdiff - process.cpp
Logo AND Algorithmique Numérique Distribuée

Private GIT Repository
Add option "-s" for controlling the minimum duration between iterations.
[loba.git] / process.cpp
index 23c7abf028cd985ef66d92264a790fed9dab9fce..34590f3f199f33be126f8111f4539b8caaf522bb 100644 (file)
@@ -65,10 +65,21 @@ process::~process()
 
 int process::run()
 {
+    double next_iter_after_date = 0.0;
     INFO1("Initial load: %g", load);
     VERB0("Starting...");
     comp_iter = lb_iter = 0;
     while (true) {
+        if (opt::min_iter_duration) {
+            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(next_iter_after_date - now);
+            }
+            next_iter_after_date = MSG_get_clock() + opt::min_iter_duration;
+        }
+
         if (load > 0.0) {
             ++comp_iter;
             if (opt::log_rate && comp_iter % opt::log_rate == 0) {