prevent timer overflow on 32 bit systems
This commit is contained in:
14
CppTimer.cpp
14
CppTimer.cpp
@ -32,19 +32,19 @@ CppTimer::CppTimer() {
|
||||
throw("Could not create timer");
|
||||
};
|
||||
|
||||
void CppTimer::start(long nanosecs,std::function<void()> callbackIn, int type) {
|
||||
void CppTimer::start(long secs, long nanosecs,std::function<void()> callbackIn, int type) {
|
||||
switch(type){
|
||||
case(PERIODIC):
|
||||
//starts after specified period of nanoseconds
|
||||
its.it_value.tv_sec = nanosecs / 1000000000;
|
||||
its.it_value.tv_nsec = nanosecs % 1000000000;
|
||||
its.it_interval.tv_sec = nanosecs / 1000000000;
|
||||
its.it_interval.tv_nsec = nanosecs % 1000000000;
|
||||
its.it_value.tv_sec = secs;
|
||||
its.it_value.tv_nsec = nanosecs;
|
||||
its.it_interval.tv_sec = secs;
|
||||
its.it_interval.tv_nsec = nanosecs;
|
||||
break;
|
||||
case(ONESHOT):
|
||||
//fires once after specified period of nanoseconds
|
||||
its.it_value.tv_sec = nanosecs / 1000000000;
|
||||
its.it_value.tv_nsec = nanosecs % 1000000000;
|
||||
its.it_value.tv_sec = secs;
|
||||
its.it_value.tv_nsec = nanosecs;
|
||||
its.it_interval.tv_sec = 0;
|
||||
its.it_interval.tv_nsec = 0;
|
||||
break;
|
||||
|
Reference in New Issue
Block a user