diff options
author | louiz’ <louiz@louiz.org> | 2017-03-14 21:45:23 +0100 |
---|---|---|
committer | louiz’ <louiz@louiz.org> | 2017-03-14 21:45:23 +0100 |
commit | 0ab40dc1ab4e689921da54080b135e1d22b1c586 (patch) | |
tree | 238ac477aa6b29a8d1e187a8d97ecbcbbbc663ef /louloulibs/utils/timed_events.cpp | |
parent | 2d3806152e854ace7533fc3ad34d4ac1c44e9687 (diff) | |
download | biboumi-0ab40dc1ab4e689921da54080b135e1d22b1c586.tar.gz biboumi-0ab40dc1ab4e689921da54080b135e1d22b1c586.tar.bz2 biboumi-0ab40dc1ab4e689921da54080b135e1d22b1c586.tar.xz biboumi-0ab40dc1ab4e689921da54080b135e1d22b1c586.zip |
Refactoring louloulibs and cmake
Use OBJECT libraries
Remove the louloulibs directory
Write FOUND variables in the cache
Diffstat (limited to 'louloulibs/utils/timed_events.cpp')
-rw-r--r-- | louloulibs/utils/timed_events.cpp | 47 |
1 files changed, 0 insertions, 47 deletions
diff --git a/louloulibs/utils/timed_events.cpp b/louloulibs/utils/timed_events.cpp deleted file mode 100644 index 5077199..0000000 --- a/louloulibs/utils/timed_events.cpp +++ /dev/null @@ -1,47 +0,0 @@ -#include <utils/timed_events.hpp> - -TimedEvent::TimedEvent(std::chrono::steady_clock::time_point&& time_point, - std::function<void()> callback, const std::string& name): - time_point(std::move(time_point)), - callback(callback), - repeat(false), - repeat_delay(0), - name(name) -{ -} - -TimedEvent::TimedEvent(std::chrono::milliseconds&& duration, - std::function<void()> callback, const std::string& name): - time_point(std::chrono::steady_clock::now() + duration), - callback(callback), - repeat(true), - repeat_delay(std::move(duration)), - name(name) -{ -} - -bool TimedEvent::is_after(const TimedEvent& other) const -{ - return this->is_after(other.time_point); -} - -bool TimedEvent::is_after(const std::chrono::steady_clock::time_point& time_point) const -{ - return this->time_point > time_point; -} - -std::chrono::milliseconds TimedEvent::get_timeout() const -{ - 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 -{ - this->callback(); -} - -const std::string& TimedEvent::get_name() const -{ - return this->name; -} |