The Timer class is used for keeping time intervals.
It may be used to perform some periodic actions. For example to print simulation statistics each second:
Timer t(1000); while (1) { // simulation... if (t.elapsed()) { // print statistics... } }
One timer's tick is equal to one millisecond.
To change timer's interval the following code can be used:
typedef long tick_type |
Tick type.
Timer | ( | ) |
Default interval.
This constructor initializes the timer's interval by one second.
Set timer's interval.
This constructor initializes the timer's interval by ms milliseconds.
[in] | ms | Timer's interval in milliseconds. |
Timer::tick_type interval | ( | ) | const |
Get timer's interval.
This method returns the current timer's interval.
bool elapsed | ( | ) | const |
Check timer.
This method checks the timer's interval is elapsed.
void force | ( | ) |
Force timer.
This method forces the timer, so next elapsed() method call will return true.