event/Chrono: add type alias TimePoint

This commit is contained in:
Max Kellermann 2021-02-05 13:05:00 +01:00 committed by Max Kellermann
parent 1b4fd74575
commit d1957b83c8
4 changed files with 4 additions and 3 deletions

View File

@ -30,6 +30,7 @@ namespace Event {
using Clock = std::chrono::steady_clock; using Clock = std::chrono::steady_clock;
using Duration = Clock::duration; using Duration = Clock::duration;
using TimePoint = Clock::time_point;
} // namespace Event } // namespace Event

View File

@ -64,7 +64,7 @@ class FineTimerEvent final
* When is this timer due? This is only valid if IsPending() * When is this timer due? This is only valid if IsPending()
* returns true. * returns true.
*/ */
Event::Clock::time_point due; Event::TimePoint due;
public: public:
FineTimerEvent(EventLoop &_loop, Callback _callback) noexcept FineTimerEvent(EventLoop &_loop, Callback _callback) noexcept

View File

@ -54,7 +54,7 @@ TimerList::Insert(FineTimerEvent &t) noexcept
} }
Event::Duration Event::Duration
TimerList::Run(const Event::Clock::time_point now) noexcept TimerList::Run(const Event::TimePoint now) noexcept
{ {
while (true) { while (true) {
auto i = timers.begin(); auto i = timers.begin();

View File

@ -71,5 +71,5 @@ public:
* duration until the next timer expires. Returns a negative * duration until the next timer expires. Returns a negative
* duration if there is no timeout. * duration if there is no timeout.
*/ */
Event::Duration Run(Event::Clock::time_point now) noexcept; Event::Duration Run(Event::TimePoint now) noexcept;
}; };