From f807345022358848e0e68a5ba75ce0a0c9c8407c Mon Sep 17 00:00:00 2001 From: Max Kellermann Date: Tue, 29 Oct 2024 13:29:21 +0100 Subject: [PATCH] event/Loop: use std::chrono::ceil() Thanks to C++17, we don't need our custom implementation anymore. --- src/event/Loop.cxx | 14 +------------- 1 file changed, 1 insertion(+), 13 deletions(-) diff --git a/src/event/Loop.cxx b/src/event/Loop.cxx index eea7415d9..a73e1e963 100644 --- a/src/event/Loop.cxx +++ b/src/event/Loop.cxx @@ -224,18 +224,6 @@ EventLoop::RunOneIdle() noexcept return true; } -template -static constexpr ToDuration -duration_cast_round_up(std::chrono::duration d) noexcept -{ - using FromDuration = decltype(d); - constexpr auto one = std::chrono::duration_cast(ToDuration(1)); - constexpr auto round_add = one > one.zero() - ? one - FromDuration(1) - : one.zero(); - return std::chrono::duration_cast(d + round_add); -} - /** * Convert the given timeout specification to a milliseconds integer, * to be used by functions like poll() and epoll_wait(). Any negative @@ -245,7 +233,7 @@ static constexpr int ExportTimeoutMS(Event::Duration timeout) noexcept { return timeout >= timeout.zero() - ? int(duration_cast_round_up(timeout).count()) + ? static_cast(std::chrono::ceil(timeout).count()) : -1; }