diff options
author | Henning Baldersheim <balder@yahoo-inc.com> | 2021-03-10 12:22:17 +0000 |
---|---|---|
committer | Henning Baldersheim <balder@yahoo-inc.com> | 2021-03-10 12:22:17 +0000 |
commit | 307ff5c6d37e3fbb258045b284e2ac8d9516e4d4 (patch) | |
tree | 61ac6e419fe2c6a3543bbe9825c1d49562c1c7ca /configd | |
parent | d9d006664e8186e20b6f03c1470a3c23774eaa2d (diff) |
Use simpler c++11 time constructions.
Diffstat (limited to 'configd')
-rw-r--r-- | configd/src/apps/sentinel/sentinel.cpp | 13 |
1 files changed, 5 insertions, 8 deletions
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"); |