00001 #ifndef __SS_WATCHDOG_H 00002 #define __SS_WATCHDOG_H 00003 00004 #include <pthread.h> 00005 00006 class WatchdogThread 00007 { 00008 protected: 00009 pthread_t thread_; 00010 pthread_mutex_t mutex_; 00011 double interval_; 00012 bool kicked_, set_; 00013 00014 public: 00015 WatchdogThread() : set_(false) { } 00016 WatchdogThread(double interval) : set_(false) { set(interval); } 00017 virtual ~WatchdogThread(); 00018 00019 bool set(double interval); 00020 bool kick(); 00021 00022 protected: 00023 virtual void watch(); 00024 virtual void bark(); 00025 00026 private: 00027 static void *watchDelegate(void *obj); 00028 }; 00029 00030 #endif /* __SS_WATCHDOG_H */