/* */ #include "TimerA2.h" namespace aria2 { Timer::Timer() : tp_(Clock::now()) { reset(); } Timer::Timer(const Clock::time_point& tp) : tp_(tp) {} void Timer::reset() { tp_ = Clock::now(); } Timer::Clock::duration Timer::difference() const { auto now = Clock::now(); if (now < tp_) { return Timer::Clock::duration(0_s); } return now - tp_; } Timer::Clock::duration Timer::difference(const Timer& timer) const { if (timer.tp_ < tp_) { return Timer::Clock::duration(0_s); } return timer.tp_ - tp_; } bool Timer::isZero() const { return tp_.time_since_epoch() == Clock::duration::zero(); } } // namespace aria2