From 307ff5c6d37e3fbb258045b284e2ac8d9516e4d4 Mon Sep 17 00:00:00 2001 From: Henning Baldersheim Date: Wed, 10 Mar 2021 12:22:17 +0000 Subject: Use simpler c++11 time constructions. --- configd/src/apps/sentinel/sentinel.cpp | 13 +++++-------- 1 file changed, 5 insertions(+), 8 deletions(-) (limited to 'configd/src') diff --git a/configd/src/apps/sentinel/sentinel.cpp b/configd/src/apps/sentinel/sentinel.cpp index b24e65cd1d9..1bca6f72d10 100644 --- a/configd/src/apps/sentinel/sentinel.cpp +++ b/configd/src/apps/sentinel/sentinel.cpp @@ -80,8 +80,7 @@ main(int argc, char **argv) return EXIT_FAILURE; } - struct timeval lastTv; - gettimeofday(&lastTv, nullptr); + vespalib::steady_time lastTime = vespalib::steady_clock::now(); while (!stop()) { try { vespalib::SignalHandler::CHLD.clear(); @@ -111,13 +110,11 @@ main(int argc, char **argv) select(maxNum, &fds, nullptr, nullptr, &tv); - gettimeofday(&tv, nullptr); - double delta = tv.tv_sec - lastTv.tv_sec - + 1e-6 * (tv.tv_usec - lastTv.tv_usec); - if (delta < 0.01) { - usleep(12500); // Avoid busy looping; + vespalib::steady_time now = vespalib::steady_clock::now(); + if ((now - lastTime) < 10ms) { + std::this_thread::sleep_for(12ms); // Avoid busy looping; } - lastTv = tv; + lastTime = now; } EV_STOPPING("config-sentinel", "normal exit"); -- cgit v1.2.3