You can not select more than 25 topics
Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
25 lines
624 B
25 lines
624 B
#include "pollingtimer.h"
|
|
#include <chrono>
|
|
|
|
void PollingTimer::start(){
|
|
shouldRun = true;
|
|
}
|
|
|
|
void PollingTimer::stop(){
|
|
shouldRun = false;
|
|
}
|
|
|
|
void PollingTimer::doLoop(){
|
|
std::chrono::steady_clock::time_point begin;
|
|
std::chrono::steady_clock::time_point end;
|
|
|
|
while(shouldRun){
|
|
begin = std::chrono::steady_clock::now();
|
|
_c->exec();
|
|
end = std::chrono::steady_clock::now();
|
|
std::this_thread::sleep_for(
|
|
std::chrono::microseconds((this->timeout)
|
|
- std::chrono::duration_cast<std::chrono::microseconds>(end - begin).count()));
|
|
}
|
|
}
|