summaryrefslogtreecommitdiffstats
path: root/fnet
diff options
context:
space:
mode:
authorHenning Baldersheim <balder@yahoo-inc.com>2022-02-25 10:18:40 +0000
committerHenning Baldersheim <balder@yahoo-inc.com>2022-02-25 10:18:40 +0000
commit8a1edcfa91f4ecd5586d1ad4496f1525dc7319b3 (patch)
tree5c15f493c9fc0fa94064b1088577ab2b1f9555fc /fnet
parent9fa74366994fa991c21db246df97377149fc37b9 (diff)
- Use the typesafe vespalib::count_ms() to correcly count ms.
- Choose tick based on VESPA_TIMER_HZ/10. VESPA_TIMER_HZ has a default of 1000hz.
Diffstat (limited to 'fnet')
-rw-r--r--fnet/src/tests/scheduling/schedule.cpp2
-rw-r--r--fnet/src/vespa/fnet/scheduler.cpp3
-rw-r--r--fnet/src/vespa/fnet/scheduler.h2
3 files changed, 4 insertions, 3 deletions
diff --git a/fnet/src/tests/scheduling/schedule.cpp b/fnet/src/tests/scheduling/schedule.cpp
index d2d1173ccbf..b61328a5901 100644
--- a/fnet/src/tests/scheduling/schedule.cpp
+++ b/fnet/src/tests/scheduling/schedule.cpp
@@ -46,7 +46,7 @@ public:
if (b < a)
return false;
- if ((b - a) > (3 * FNET_Scheduler::tick_ms.count()))
+ if ((b - a) > (3 * vespalib::count_ms(FNET_Scheduler::tick_ms)))
return false;
return true;
diff --git a/fnet/src/vespa/fnet/scheduler.cpp b/fnet/src/vespa/fnet/scheduler.cpp
index ba1e9f57f4a..c6b1263bf61 100644
--- a/fnet/src/vespa/fnet/scheduler.cpp
+++ b/fnet/src/vespa/fnet/scheduler.cpp
@@ -8,6 +8,7 @@
#include <vespa/log/log.h>
LOG_SETUP(".fnet.scheduler");
+const vespalib::duration FNET_Scheduler::tick_ms = vespalib::from_s(10*1.0/vespalib::getVespaTimerHz());
FNET_Scheduler::FNET_Scheduler(vespalib::steady_time *sampler)
: _cond(),
@@ -65,7 +66,7 @@ FNET_Scheduler::Schedule(FNET_Task *task, double seconds)
{
constexpr double ONE_MONTH_S = 3600 * 24 * 30;
seconds = std::min(seconds, ONE_MONTH_S);
- uint32_t ticks = 2 + (uint32_t) std::ceil(seconds * (1000.0 / tick_ms.count()));
+ uint32_t ticks = 2 + (uint32_t) std::ceil(seconds * (1000.0 / vespalib::count_ms(tick_ms)));
std::lock_guard<std::mutex> guard(_lock);
if (!task->_killed) {
diff --git a/fnet/src/vespa/fnet/scheduler.h b/fnet/src/vespa/fnet/scheduler.h
index 0a6c9259ccc..d9a65efde34 100644
--- a/fnet/src/vespa/fnet/scheduler.h
+++ b/fnet/src/vespa/fnet/scheduler.h
@@ -20,7 +20,7 @@ class FNET_Scheduler
{
public:
using clock = vespalib::steady_clock;
- static constexpr auto tick_ms = 10ms;
+ static const vespalib::duration tick_ms;
enum scheduler_constants {
NUM_SLOTS = 4096,