I need a timer to execute callbacks with relatively low resolution. What\'s the best way to implement such C++ timer class in Linux? Are there any libraries I could use?
The timeval struct from the time.h header is what you are looking for. It has time in seconds and nanoseconds. So total time in nanoseconds is timeval.tv_sec * 1000000 + timeval.tv_usec. Easy enough, I think.
#include
timeval theStartTime;
gettimeofday(&theStartTime);
std::cout<<"The time we got's seconds field = "<