Go to the documentation of this file.00001
00019 #ifndef COIL_TIME_H
00020 #define COIL_TIME_H
00021
00022 #include <unistd.h>
00023 #include <sys/time.h>
00024 #include <sys/types.h>
00025 #include <time.h>
00026 #include <iostream>
00027 #include <coil/config_coil.h>
00028 #include <coil/TimeValue.h>
00029
00030 namespace coil
00031 {
00032
00054 inline unsigned int sleep(unsigned int seconds)
00055 {
00056 return ::sleep(seconds);
00057 }
00058
00080 inline int sleep(TimeValue interval)
00081 {
00082 timeval tv;
00083 tv.tv_sec = interval.sec();
00084 tv.tv_usec = interval.usec();
00085 return ::select(0, 0, 0, 0, &tv);
00086 }
00087
00109 inline int usleep(useconds_t usec)
00110 {
00111 return ::usleep(usec);
00112 }
00113
00137 inline int gettimeofday(struct timeval *tv, struct timezone *tz)
00138 {
00139 return ::gettimeofday(tv, tz);
00140 }
00141
00159 inline TimeValue gettimeofday()
00160 {
00161 timeval tv;
00162 ::gettimeofday(&tv, 0);
00163 return TimeValue(tv.tv_sec, tv.tv_usec);
00164 }
00165
00189 inline int settimeofday(const struct timeval *tv , const struct timezone *tz)
00190 {
00191 return ::settimeofday(tv, tz);
00192 }
00193
00194
00195 };
00196
00197 #endif // COIL_TIME_H