aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
-rw-r--r--fnet/src/vespa/fnet/scheduler.cpp3
-rw-r--r--jrt/src/com/yahoo/jrt/Scheduler.java2
2 files changed, 3 insertions, 2 deletions
diff --git a/fnet/src/vespa/fnet/scheduler.cpp b/fnet/src/vespa/fnet/scheduler.cpp
index 6c8340c1ff8..d9229cd4843 100644
--- a/fnet/src/vespa/fnet/scheduler.cpp
+++ b/fnet/src/vespa/fnet/scheduler.cpp
@@ -3,6 +3,7 @@
#include "scheduler.h"
#include "task.h"
#include <sstream>
+#include <cmath>
#include <vespa/log/log.h>
LOG_SETUP(".fnet.scheduler");
@@ -68,7 +69,7 @@ FNET_Scheduler::~FNET_Scheduler()
void
FNET_Scheduler::Schedule(FNET_Task *task, double seconds)
{
- uint32_t ticks = 1 + (uint32_t) (seconds * (1000 / SLOT_TICK) + 0.5);
+ uint32_t ticks = 1 + (uint32_t) std::ceil(seconds * (1000.0 / SLOT_TICK));
std::lock_guard<std::mutex> guard(_lock);
if (!task->_killed) {
diff --git a/jrt/src/com/yahoo/jrt/Scheduler.java b/jrt/src/com/yahoo/jrt/Scheduler.java
index 57b5ac43cea..ae5a827076e 100644
--- a/jrt/src/com/yahoo/jrt/Scheduler.java
+++ b/jrt/src/com/yahoo/jrt/Scheduler.java
@@ -61,7 +61,7 @@ class Scheduler {
if (seconds < 0.0) {
throw new IllegalArgumentException("cannot schedule a Task in the past");
}
- int ticks = 1 + (int) (seconds * 10.0 + 0.5);
+ int ticks = 1 + (int) Math.ceil(seconds * (1000.0 / TICK));
if (isActive(task)) {
linkOut(task);
}