24 using namespace basis;
29 heartbeat::heartbeat(
int misses_allowed,
int check_interval)
34 {
reset(misses_allowed, check_interval); }
54 void heartbeat::reset_next_beat()
55 { *_next_heartbeat =
time_stamp(_check_interval); }
64 return (_misses > _misses_allowed)
65 || (
due() && (_misses >= _misses_allowed));
70 _misses_allowed = misses_allowed;
72 _check_interval = check_interval;
80 : astring::empty_string());
83 to_return +=
a_sprintf(
", missed=%d, interval=%d, ",
92 if (
this == &to_copy)
return *
this;
93 _check_interval = to_copy._check_interval;
94 _misses_allowed = to_copy._misses_allowed;
95 _misses = to_copy._misses;
96 *_next_heartbeat = *to_copy._next_heartbeat;
a_sprintf is a specialization of astring that provides printf style support.
Provides a dynamically resizable ASCII character string.
Monitors a periodic heartbeat to track a resource's health.
void made_request()
records that another heartbeat request was sent out.
int misses_left() const
the number of misses that this object is still allowed.
int checking_interval() const
returns the period of the heartbeats.
heartbeat & operator=(const heartbeat &to_copy)
timely::time_stamp heartbeat_time() const
returns the time when the next heartbeat will be requested.
void reset(int misses_allowed, int check_interval)
retrains the heartbeat monitor for a new configuration.
bool due() const
is the next heartbeat due yet?
int missed_so_far() const
returns the number of heartbeat responses that are pending.
int time_left() const
number of milliseconds left before the next beat will be requested.
heartbeat(int misses_allowed=500, int check_interval=10000)
creates a heartbeat monitor with the specified interval and maximum skips permitted.
bool dead() const
is this object considered dead from missing too many heartbeats?
basis::astring text_form(bool detailed=false) const
returns a readable form of the heartbeat's information.
void kabump()
registers a heartbeat response and sets the state to healthy.
Represents a point in time relative to the operating system startup time.
basis::astring text_form(stamp_display_style style=STAMP_RELATIVE) const
returns a simple textual representation of the time_stamp.
time_representation value() const
returns the time_stamp in terms of the lower level type.
The guards collection helps in testing preconditions and reporting errors.
void WHACK(contents *&ptr)
deletion with clearing of the pointer.