Implement Timer::expired_cont()
Returns true if the timer is not running, effectively allowing to check if a certain set time in the future has passed.
This commit is contained in:
parent
dc2d596f40
commit
8d9d367d6b
@ -77,5 +77,11 @@ T Timer<T>::elapsed() {
|
|||||||
return m_isRunning ? (_millis() - m_started) : 0;
|
return m_isRunning ? (_millis() - m_started) : 0;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
template<typename T>
|
||||||
|
bool Timer<T>::expired_cont(T msPeriod)
|
||||||
|
{
|
||||||
|
return !m_isRunning || expired(msPeriod);
|
||||||
|
}
|
||||||
|
|
||||||
template class Timer<unsigned long>;
|
template class Timer<unsigned long>;
|
||||||
template class Timer<unsigned short>;
|
template class Timer<unsigned short>;
|
||||||
|
@ -21,8 +21,9 @@ public:
|
|||||||
void start();
|
void start();
|
||||||
void stop(){m_isRunning = false;}
|
void stop(){m_isRunning = false;}
|
||||||
bool running()const {return m_isRunning;}
|
bool running()const {return m_isRunning;}
|
||||||
bool expired(T msPeriod);
|
bool expired(T msPeriod); // returns true only once after expiration, then stops running
|
||||||
T elapsed();
|
T elapsed(); // returns the time in milliseconds since the timer was started or 0 otherwise
|
||||||
|
bool expired_cont(T msPeriod); // return true when continuosly when expired / not running
|
||||||
protected:
|
protected:
|
||||||
T started()const {return m_started;}
|
T started()const {return m_started;}
|
||||||
private:
|
private:
|
||||||
|
Loading…
Reference in New Issue
Block a user