#include "timer.hh" /** * \author cpellegrino */ bool Timer::hasExpiredWrt(Timer const& t) const { if (t.tv_sec > tv_sec) return true; if (t.tv_sec < tv_sec) return false; if (t.tv_usec > tv_usec) return true; return false; } bool Timer::hasExpired() const { Timer const t(0, 0); return Timer::hasExpiredWrt(t); } void Timer::set(long int seconds, long int useconds) { static const int usec_in_a_sec = 1000000; gettimeofday(this, 0); tv_sec += seconds; tv_usec += useconds; tv_sec += (tv_usec) / usec_in_a_sec; tv_usec %= usec_in_a_sec; }