26 #ifndef Common_Timer_h
27 #define Common_Timer_h
54 Timer(uint32_t millis,
bool start_timer =
false)
82 std::chrono::fast_clock::duration::zero();
89 void reset(
bool start_timer =
false) {
106 return std::chrono::duration_cast<std::chrono::milliseconds>(
m_remaining).count();
128 return (uint32_t)std::chrono::duration_cast<std::chrono::milliseconds>(
m_duration).count();
154 #endif // Common_Timer_h
chrono::time_point< fast_clock > time_point
void stop()
Stops the timer.
Timer(uint32_t millis, bool start_timer=false)
Constructor; assigns number of milliseconds after which the timer will expire.
std::chrono::fast_clock::duration m_duration
The duration of the timer.
Declarations for fast_clock.
bool m_running
True if the timer is running.
uint32_t remaining()
Returns the remaining time till expiry.
bool expired()
Returns true if the timer is expired.
void reset(bool start_timer=false)
Resets the timer.
static time_point now() noexcept
uint32_t duration()
Returns the duration of the timer.
bool m_started
True if the timer was started.
void start()
Starts the timer.
A timer class to keep timeout states across AsyncComm related calls.
std::chrono::fast_clock::time_point start_time
The time when the timer was started.
bool is_running()
Returns true if the timer is still running (not yet expired.
std::chrono::fast_clock::duration m_remaining
The remaining time till expiration.