00001 #ifndef HEARTBEAT_CLASS
00002 #define HEARTBEAT_CLASS
00003
00004
00005
00006
00007
00008
00009
00010
00011
00012
00013
00014
00015
00016
00017
00018 #include "mechanisms_dll.h"
00019
00020 #include <basis/object_base.h>
00021
00022
00023 class time_stamp;
00024
00026
00034 class MECHANISMS_CLASS_STYLE heartbeat : public virtual object_base
00035 {
00036 public:
00037 heartbeat(int misses_allowed = 500, int check_interval = 10000);
00039
00042 heartbeat(const heartbeat &to_copy);
00043
00044 ~heartbeat();
00045
00046 IMPLEMENT_CLASS_NAME("heartbeat");
00047
00048 heartbeat &operator =(const heartbeat &to_copy);
00049
00050 istring text_form(bool detailed = false) const;
00052
00053 void reset(int misses_allowed, int check_interval);
00055
00056 bool due() const;
00058
00059 bool dead() const;
00061
00066 void made_request();
00068
00071 inline void need_beat() { made_request(); }
00073
00074 void kabump();
00076
00079 inline void recycle() { kabump(); }
00081
00082
00083
00084 inline int missed_so_far() const { return _misses; }
00086 inline int misses_left() const { return _misses_allowed - _misses; }
00088
00089 inline int allowed_misses() const { return _misses_allowed; }
00091 inline int checking_interval() const { return _check_interval; }
00093
00094 time_stamp heartbeat_time() const;
00096
00099 int time_left() const;
00101
00103 private:
00104 time_stamp *_next_heartbeat;
00105 int _check_interval;
00106 int _misses_allowed;
00107 int _misses;
00108
00109 void reset_next_beat();
00110 };
00111
00112 #endif
00113