From 3b1bb63be5c074e95092f441baadce91070669af Mon Sep 17 00:00:00 2001
From: =?UTF-8?q?Ma=C3=ABl=20Madon?= <mael.madon@irit.fr>
Date: Thu, 4 May 2023 15:00:22 +0200
Subject: [PATCH] fix: more robust CALL_ME_LATER date checking. Related to
 issue #12

---
 src/users/dynscheduler.cpp | 6 ++++--
 1 file changed, 4 insertions(+), 2 deletions(-)

diff --git a/src/users/dynscheduler.cpp b/src/users/dynscheduler.cpp
index 1a6263d..f0b3b00 100644
--- a/src/users/dynscheduler.cpp
+++ b/src/users/dynscheduler.cpp
@@ -4,8 +4,10 @@
 #include "../pempek_assert.hpp"
 #include "json_workload.hpp"
 #include "loguru.hpp"
+#include <cmath>
 #include <limits>
 #include <map>
+#include <math.h>
 #include <string>
 
 DynScheduler::DynScheduler(Workload *workload, SchedulingDecision *decision,
@@ -86,7 +88,7 @@ void DynScheduler::make_decisions(double date,
         /* Time of next_submission might have changed in response to feedback */
         double new_date_of_next_submission = broker->next_submission(date);
 
-        if (abs(date - new_date_of_next_submission) < .00001)
+        if (new_date_of_next_submission == lround(date))
         {
             submit_broker_jobs(date);
             new_date_of_next_submission = broker->next_submission(date);
@@ -115,7 +117,7 @@ void DynScheduler::on_requested_call(double date)
     ISchedulingAlgorithm::on_requested_call(date);
 
     /* Check if this call concerns the broker */
-    if (broker_enabled && abs(date - broker->next_submission(date)) < .00001)
+    if (broker_enabled && broker->next_submission(date) == lround(date))
     {
         /* Handle the jobs to submit */
         submit_broker_jobs(date);
-- 
GitLab