heartbeat.h

Go to the documentation of this file.
00001 #ifndef HEARTBEAT_CLASS
00002 #define HEARTBEAT_CLASS
00003 
00004 /*****************************************************************************\
00005 *                                                                             *
00006 *  Name   : heartbeat                                                         *
00007 *  Author : Chris Koeritz                                                     *
00008 *                                                                             *
00009 *******************************************************************************
00010 * Copyright (c) 1996-$now By Author.  This program is free software; you can  *
00011 * redistribute it and/or modify it under the terms of the GNU General Public  *
00012 * License as published by the Free Software Foundation; either version 2 of   *
00013 * the License or (at your option) any later version.  This is online at:      *
00014 *     http://www.fsf.org/copyleft/gpl.html                                    *
00015 * Please send any updates to: fred@gruntose.com                               *
00016 \*****************************************************************************/
00017 
00018 #include "mechanisms_dll.h"
00019 
00020 #include <basis/object_base.h>
00021 
00022 // forward.
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   // reporting functions for internal state...
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 

Generated on Thu Nov 20 04:28:59 2008 for HOOPLE Libraries by  doxygen 1.5.1