A C++ Library to handle linux interval timer
Each timer type can exist only once per application.
- ITimer_Real counts down in real time.
- ITimer_Virtual counts down against the user-mode CPU time consumed by the process.
- ITimer_Prof counts down against the total CPU time consumed by the process.
In the following replace ITimer_XXX with the desired timer type.
const timeval interval = {1, 0}; cxxitimer::ITimer_XXX itimer(interval);
const double interval = 1.0; cxxitimer::ITimer_XXX itimer(interval);
const timeval initial_interval = {2, 0}; const timeval interval = {1, 0}; cxxitimer::ITimer_XXX itimer(interval, initial_interval);
const double initial_interval = 2.0; const double interval = 1.0; cxxitimer::ITimer_XXX itimer(interval, initial_interval);
itimer.start();
itimer.stop();
Note: Timer must be stopped.
const timeval interval = {1, 500'000}; itimer.set_interval(interval);
const double interval = 2.5; itimer.set_interval(interval);
Note: can be applied it the timer is running
// slow down timer itmer.set_speed_factor(0.75);
// speed up timer itmer.set_speed_factor(1.25);
// reset timer to original interval
itimer.set_speed_to_normal();