From 1e1ccbff5cc4f4ec7d870ea1db985b08e37ed3f8 Mon Sep 17 00:00:00 2001 From: Yuqian Yang Date: Mon, 3 Nov 2025 15:51:46 +0800 Subject: Use TimerRegistry in UnixEventLoop. --- include/cru/base/Timer.h | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) (limited to 'include/cru/base/Timer.h') diff --git a/include/cru/base/Timer.h b/include/cru/base/Timer.h index 80929f17..dac66c6a 100644 --- a/include/cru/base/Timer.h +++ b/include/cru/base/Timer.h @@ -83,13 +83,13 @@ class TimerRegistry : public Object2 { } /** - * Returns 0 if there is no timer. + * Returns nullopt if there is no timer. */ - std::chrono::milliseconds NextTimeout( + std::optional NextTimeout( std::chrono::steady_clock::time_point now) { std::unique_lock lock(mutex_); - if (timers_.empty()) return std::chrono::milliseconds::zero(); + if (timers_.empty()) return std::nullopt; return std::ranges::min( timers_ | std::views::transform([now](const TimerData& timer) { -- cgit v1.2.3