24 #include <utils/time/wait.h> 25 #include <utils/time/time.h> 26 #include <utils/time/clock.h> 51 __desired_loop_time = desired_loop_time_usec;
54 __until_systime =
new Time();
63 delete __until_systime;
73 *__until += __desired_loop_time;
75 *__until_systime += __desired_loop_time;
87 long int remaining_usec = (*__until - *__now).in_usec();
88 while ( remaining_usec > 0 ) {
89 usleep(remaining_usec);
91 remaining_usec = (*__until - *__now).in_usec();
106 long int remaining_usec = (*__until_systime - *__now).in_usec();
107 while ( remaining_usec > 0 ) {
108 usleep(remaining_usec);
110 remaining_usec = (*__until_systime - *__now).in_usec();
124 if ( usec < 0 )
return;
125 struct timeval start, now;
126 long int remaining_usec = usec;
127 gettimeofday(&start, NULL);
129 usleep(remaining_usec);
130 gettimeofday(&now, NULL);
131 }
while ((remaining_usec = usec -
time_diff_usec(now, start)) > 0);
145 if ( usec < 0 )
return;
147 struct timeval start, now;
148 long int remaining_usec = usec;
151 usleep(remaining_usec);
153 }
while ((remaining_usec = usec -
time_diff_usec(now, start)) > 0);
void wait()
Wait until minimum loop time has been reached.
static Clock * instance()
Clock initializer.
void get_time(struct timeval *tv) const
Returns the time of the selected time source.
TimeWait(Clock *clock, long int desired_loop_time_usec)
Constructor.
Fawkes library namespace.
void get_systime(struct timeval *tv) const
Returns the system time.
This is supposed to be the central clock in Fawkes.
A class for handling time.
void wait_systime()
Wait until minimum loop time has been reached in real time.
long int time_diff_usec(const timeval &a, const timeval &b)
Get difference between two time structs in microseconds.
void mark_start()
Mark start of loop.