aboutsummaryrefslogtreecommitdiff
path: root/include/cru/base/Timer.h
diff options
context:
space:
mode:
authorYuqian Yang <crupest@crupest.life>2025-11-03 15:51:46 +0800
committerYuqian Yang <crupest@crupest.life>2025-11-03 15:51:46 +0800
commit1e1ccbff5cc4f4ec7d870ea1db985b08e37ed3f8 (patch)
tree98962fdd8ca9a08098706b05acb4ed400b0a653a /include/cru/base/Timer.h
parent9c897e8727d90345c2db7f36f52ab678778db936 (diff)
downloadcru-1e1ccbff5cc4f4ec7d870ea1db985b08e37ed3f8.tar.gz
cru-1e1ccbff5cc4f4ec7d870ea1db985b08e37ed3f8.tar.bz2
cru-1e1ccbff5cc4f4ec7d870ea1db985b08e37ed3f8.zip
Use TimerRegistry in UnixEventLoop.
Diffstat (limited to 'include/cru/base/Timer.h')
-rw-r--r--include/cru/base/Timer.h6
1 files changed, 3 insertions, 3 deletions
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<std::chrono::milliseconds> 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) {