Jpp test-rotations-old
the software that should make you happy
Loading...
Searching...
No Matches
timer.cc
Go to the documentation of this file.
1#include "timer.hh"
2
3/**
4 * \author cpellegrino
5 */
6
7bool Timer::hasExpiredWrt(Timer const& t) const
8{
9 if (t.tv_sec > tv_sec)
10 return true;
11
12 if (t.tv_sec < tv_sec)
13 return false;
14
15 if (t.tv_usec > tv_usec)
16 return true;
17
18 return false;
19}
20
22{
23 Timer const t(0, 0);
24 return Timer::hasExpiredWrt(t);
25}
26
27void Timer::set(long int seconds, long int useconds)
28{
29 static const int usec_in_a_sec = 1000000;
30
31 gettimeofday(this, 0);
32
33 tv_sec += seconds;
34 tv_usec += useconds;
35 tv_sec += (tv_usec) / usec_in_a_sec;
36 tv_usec %= usec_in_a_sec;
37}
Definition timer.hh:11
bool hasExpiredWrt(Timer const &t) const
Definition timer.cc:7
void set(long int seconds, long int useconds)
Definition timer.cc:27
bool hasExpired() const
Definition timer.cc:21