MySQL 26.10.0
Source Code Documentation
hm::Mode_Timer Class Reference

Server mode timer used for fallback mode, recovery mode, etc. More...

#include <health_monitor_timer.h>

Public Member Functions

 Mode_Timer ()=default
 
 Mode_Timer (std::string &name, const int interval)
 
void start ()
 Mode Timer - Start. More...
 
void stop ()
 
void cancel ()
 Mode Timer - Cancel. More...
 
void reset ()
 Mode Timer - Reset. More...
 
void set_timeout (int timeout)
 Mode Timer - Set timeout. More...
 
void adjust_timeout ()
 Mode Timer - Adjust timeout. More...
 
void tick ()
 Mode Timer - Tick. More...
 
bool report_status () const
 Mode Timer - Report status. More...
 
std::string format_status () const
 Mode Timer - Format status. More...
 
bool canceled () const
 
void set_canceled (bool canceled)
 
bool expired () const
 
int interval () const
 
void set_interval (int interval)
 
int report_interval () const
 
void set_report_interval (int interval)
 
int remaining () const
 Mode Timer - Remaining time. More...
 
bool running () const
 
bool started () const
 
int timeout () const
 
std::string name () const
 
void set_name (const std::string name)
 
std::string running_msg () const
 
void set_running_msg (const std::string &msg)
 

Private Attributes

std::string m_name
 
int m_timer {0}
 
int m_interval {k_default_timer_interval}
 
int m_report_interval {k_default_report_interval}
 
int m_timeout {0}
 
bool m_running {false}
 
bool m_started {false}
 
bool m_expired {false}
 
bool m_canceled {false}
 
std::string m_running_msg
 

Detailed Description

Server mode timer used for fallback mode, recovery mode, etc.

  • Time-based interval, driven by the collection cycle, i.e. one tick per cycle
  • Timer interval (tick) is the base monitoring interval of the collector (10s)
  • Reporting interval is the interval of issuing status messages, and should be a multiple of the timer interval

NOTE: This timer assumes a constant Collector base interval. If the base interval is dynamic, then the Mode_Timer must be modified to use the current Collector base interval for the tick interval.

Constructor & Destructor Documentation

◆ Mode_Timer() [1/2]

hm::Mode_Timer::Mode_Timer ( )
default

◆ Mode_Timer() [2/2]

hm::Mode_Timer::Mode_Timer ( std::string &  name,
const int  interval 
)
inline

Member Function Documentation

◆ adjust_timeout()

void hm::Mode_Timer::adjust_timeout ( )

Mode Timer - Adjust timeout.

  • Round up timeout to the next interval

◆ cancel()

void hm::Mode_Timer::cancel ( )

Mode Timer - Cancel.

  • Reset everything
  • Set canceled flag

◆ canceled()

bool hm::Mode_Timer::canceled ( ) const
inline

◆ expired()

bool hm::Mode_Timer::expired ( ) const
inline

◆ format_status()

std::string hm::Mode_Timer::format_status ( ) const

Mode Timer - Format status.

  • Return formatted string with timer settings

◆ interval()

int hm::Mode_Timer::interval ( ) const
inline

◆ name()

std::string hm::Mode_Timer::name ( ) const
inline

◆ remaining()

int hm::Mode_Timer::remaining ( ) const

Mode Timer - Remaining time.

  • Return seconds remaining or 0.
  • The timer can continue running beyond the timeout.

◆ report_interval()

int hm::Mode_Timer::report_interval ( ) const
inline

◆ report_status()

bool hm::Mode_Timer::report_status ( ) const

Mode Timer - Report status.

  • Return true if it's time to issue a status message

◆ reset()

void hm::Mode_Timer::reset ( )

Mode Timer - Reset.

  • Reset timer state

◆ running()

bool hm::Mode_Timer::running ( ) const
inline

◆ running_msg()

std::string hm::Mode_Timer::running_msg ( ) const
inline

◆ set_canceled()

void hm::Mode_Timer::set_canceled ( bool  canceled)
inline

◆ set_interval()

void hm::Mode_Timer::set_interval ( int  interval)
inline

◆ set_name()

void hm::Mode_Timer::set_name ( const std::string  name)
inline

◆ set_report_interval()

void hm::Mode_Timer::set_report_interval ( int  interval)
inline

◆ set_running_msg()

void hm::Mode_Timer::set_running_msg ( const std::string &  msg)
inline

◆ set_timeout()

void hm::Mode_Timer::set_timeout ( int  timeout)

Mode Timer - Set timeout.

  • Set the timeout value then adjust if necessary

◆ start()

void hm::Mode_Timer::start ( )

Mode Timer - Start.

  • Reset state
  • Start countdown

◆ started()

bool hm::Mode_Timer::started ( ) const
inline

◆ stop()

void hm::Mode_Timer::stop ( )
inline

◆ tick()

void hm::Mode_Timer::tick ( )

Mode Timer - Tick.

  • Advance the countdown timer
  • If expired, must be stopped by the caller

◆ timeout()

int hm::Mode_Timer::timeout ( ) const
inline

Member Data Documentation

◆ m_canceled

bool hm::Mode_Timer::m_canceled {false}
private

◆ m_expired

bool hm::Mode_Timer::m_expired {false}
private

◆ m_interval

int hm::Mode_Timer::m_interval {k_default_timer_interval}
private

◆ m_name

std::string hm::Mode_Timer::m_name
private

◆ m_report_interval

int hm::Mode_Timer::m_report_interval {k_default_report_interval}
private

◆ m_running

bool hm::Mode_Timer::m_running {false}
private

◆ m_running_msg

std::string hm::Mode_Timer::m_running_msg
private

◆ m_started

bool hm::Mode_Timer::m_started {false}
private

◆ m_timeout

int hm::Mode_Timer::m_timeout {0}
private

◆ m_timer

int hm::Mode_Timer::m_timer {0}
private

The documentation for this class was generated from the following files: