summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorlouiz’ <louiz@louiz.org>2017-03-07 18:27:27 +0100
committerlouiz’ <louiz@louiz.org>2017-03-07 18:27:27 +0100
commitcd92baae3f0de8b841b5bbfdb02e4fa95acd52c1 (patch)
tree5dfb05f70f630face056536bee9387d2b4d57e04
parent6cb7787512a5e02ad2100dbdef734b36d8a8f0d5 (diff)
downloadbiboumi-cd92baae3f0de8b841b5bbfdb02e4fa95acd52c1.tar.gz
biboumi-cd92baae3f0de8b841b5bbfdb02e4fa95acd52c1.tar.bz2
biboumi-cd92baae3f0de8b841b5bbfdb02e4fa95acd52c1.tar.xz
biboumi-cd92baae3f0de8b841b5bbfdb02e4fa95acd52c1.zip
Little refactor in timed_events
Also makes the coverage code deterministic
-rw-r--r--louloulibs/utils/timed_events.cpp6
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