From 48fec7d25039949480cdfc59352b3c10b9c2c510 Mon Sep 17 00:00:00 2001 From: Alexey Ozeritskiy Date: Thu, 7 Dec 2023 20:06:15 +0100 Subject: [PATCH] Style: rename methods --- coroio/base.hpp | 14 +++++++------- coroio/poller.hpp | 16 ++++++++-------- 2 files changed, 15 insertions(+), 15 deletions(-) diff --git a/coroio/base.hpp b/coroio/base.hpp index 1fa4d9b..b8a9ff4 100644 --- a/coroio/base.hpp +++ b/coroio/base.hpp @@ -45,14 +45,14 @@ struct TEvent { template inline std::tuple -GetDurationPair(TTime now, TTime deadline, std::chrono::milliseconds min_duration) +GetDurationPair(TTime now, TTime deadline, std::chrono::milliseconds maxDuration) { if (now > deadline) { return std::make_tuple(T1(0), T2(0)); } else { auto duration = (deadline - now); - if (duration > min_duration) { - duration = min_duration; + if (duration > maxDuration) { + duration = maxDuration; } auto part1 = std::chrono::duration_cast(duration); duration -= part1; @@ -62,9 +62,9 @@ GetDurationPair(TTime now, TTime deadline, std::chrono::milliseconds min_duratio } } -inline timeval GetTimeval(TTime now, TTime deadline, std::chrono::milliseconds min_duration) +inline timeval GetTimeval(TTime now, TTime deadline, std::chrono::milliseconds maxDuration) { - auto [p1, p2] = GetDurationPair(now, deadline, min_duration); + auto [p1, p2] = GetDurationPair(now, deadline, maxDuration); return {p1.count(), static_cast(p2.count())}; } @@ -73,9 +73,9 @@ inline int GetMillis(TTime now, TTime deadline, std::chrono::milliseconds min_du return tv.tv_sec * 1000 + tv.tv_usec / 1000; } -inline timespec GetTimespec(TTime now, TTime deadline, std::chrono::milliseconds min_duration) +inline timespec GetTimespec(TTime now, TTime deadline, std::chrono::milliseconds maxDuration) { - auto [p1, p2] = GetDurationPair(now, deadline, min_duration); + auto [p1, p2] = GetDurationPair(now, deadline, maxDuration); return {p1.count(), p2.count()}; } diff --git a/coroio/poller.hpp b/coroio/poller.hpp index cae90c6..f541601 100644 --- a/coroio/poller.hpp +++ b/coroio/poller.hpp @@ -89,21 +89,21 @@ class TPollerBase { } } - void SetMinDuration(std::chrono::milliseconds minDuration) { - MinDuration_ = minDuration; - MinDurationTs_ = GetMinDuration(MinDuration_); + void SetMaxDuration(std::chrono::milliseconds maxDuration) { + MaxDuration_ = maxDuration; + MaxDurationTs_ = GetMaxDuration(MaxDuration_); } protected: timespec GetTimeout() const { return Timers_.empty() - ? MinDurationTs_ + ? MaxDurationTs_ : Timers_.top().Deadline == TTime{} ? timespec {0, 0} - : GetTimespec(TClock::now(), Timers_.top().Deadline, MinDuration_); + : GetTimespec(TClock::now(), Timers_.top().Deadline, MaxDuration_); } - static constexpr timespec GetMinDuration(std::chrono::milliseconds duration) { + static constexpr timespec GetMaxDuration(std::chrono::milliseconds duration) { auto p1 = std::chrono::duration_cast(duration); auto p2 = std::chrono::duration_cast(duration - p1); return {p1.count(), p2.count()}; @@ -136,8 +136,8 @@ class TPollerBase { std::vector ReadyEvents_; std::priority_queue Timers_; TTime LastTimersProcessTime_; - std::chrono::milliseconds MinDuration_ = std::chrono::milliseconds(100); - timespec MinDurationTs_ = GetMinDuration(MinDuration_); + std::chrono::milliseconds MaxDuration_ = std::chrono::milliseconds(100); + timespec MaxDurationTs_ = GetMaxDuration(MaxDuration_); }; } // namespace NNet