Template Class Timeout

Class Documentation

template<uint32_t (*T)()>
class Timeout

A class for keeping track of a timer that expires. Template argument expects a function pointer that returns a uin32_t representing some absolute measure of time.

Doesn’t start until restart() is called

Public Functions

inline Timeout()
inline explicit Timeout(uint32_t timeout)
inline void restart(uint32_t timeout)

Set the timer to expire in timeout units of time.

Parameters:

timeout[in] the amount of time from when this function is called that the timer should expire.

inline void stop()

Stop the timer. If expired, the expiration flags are cleared.

inline bool isStopped() const
Returns:

true if the timer is stopped

inline bool isExpired() const
Returns:

true if the timer has expired (timeout has been reached) and is NOT stopped.

inline uint32_t timeRemaining() const
Returns:

time left in timer if still running and not yet expired

inline bool execute()

Returns true on the first call when timer has expired since restart. Use to only catch the timeout expiration once.

Returns:

true the first time the timer has expired (timeout has been reached) since last restart()

Public Static Attributes

static auto TimeFunc = T