auto t = n->Update();
timeout_ms = std::min(t, timeout_ms);
}
- // For unsigned types, convert to float to avoid wrap around
- nsecs_t sleep_timeout_ns =
- static_cast<nsecs_t>(timeout_ms.count() * 1000.0f * 1000.0f);
+
+ nsecs_t sleep_timeout_ns = std::numeric_limits<nsecs_t>::max();
+ if (timeout_ms.count() < sleep_timeout_ns / 1000 / 1000) {
+ sleep_timeout_ns = timeout_ms.count() * 1000 * 1000;
+ }
// VERBOSE level won't print by default in user/userdebug build
LOG(VERBOSE) << "NodeLooperThread will wait for " << sleep_timeout_ns
<< "ns";
bool threadLoop() override;
void onFirstRef() override;
- // std::chrono::milliseconds::max() is too long
- // maintain the list every 60 seconds as the overhead
- // to loop is not too much if nothing changes
- static constexpr auto kMaxUpdatePeriod =
- std::chrono::milliseconds(60 * 1000);
+ static constexpr auto kMaxUpdatePeriod = std::chrono::milliseconds::max();
std::vector<std::unique_ptr<Node>> nodes_; // parsed from Config