diff options
Diffstat (limited to 'louloulibs')
-rw-r--r-- | louloulibs/utils/timed_events.cpp | 6 |
1 files changed, 2 insertions, 4 deletions
diff --git a/louloulibs/utils/timed_events.cpp b/louloulibs/utils/timed_events.cpp index 68d009c..5077199 100644 --- a/louloulibs/utils/timed_events.cpp +++ b/louloulibs/utils/timed_events.cpp @@ -32,10 +32,8 @@ bool TimedEvent::is_after(const std::chrono::steady_clock::time_point& time_poin std::chrono::milliseconds TimedEvent::get_timeout() const { - auto now = std::chrono::steady_clock::now(); - if (now > this->time_point) - return std::chrono::milliseconds(0); - return std::chrono::duration_cast<std::chrono::milliseconds>(this->time_point - now); + auto diff = std::chrono::duration_cast<std::chrono::milliseconds>(this->time_point - std::chrono::steady_clock::now()); + return std::max(diff, 0ms); } void TimedEvent::execute() const |