llwatchdog.h

Go to the documentation of this file.
00001 
00032 #ifndef LL_LLTHREADWATCHDOG_H
00033 #define LL_LLTHREADWATCHDOG_H
00034 
00035 #ifndef LL_TIMER_H                                      
00036         #include "lltimer.h"
00037 #endif
00038 
00039 // LLWatchdogEntry is the interface used by the tasks that 
00040 // need to be watched.
00041 class LLWatchdogEntry
00042 {
00043 public:
00044         LLWatchdogEntry();
00045         virtual ~LLWatchdogEntry();
00046 
00047         // isAlive is accessed by the watchdog thread.
00048         // This may mean that resources used by 
00049         // isAlive and other method may need synchronization.
00050         virtual bool isAlive() const = 0;
00051         virtual void start();
00052         virtual void stop();
00053 };
00054 
00055 class LLWatchdogTimeout : public LLWatchdogEntry
00056 {
00057 public:
00058         LLWatchdogTimeout();
00059         virtual ~LLWatchdogTimeout();
00060 
00061         /* virtual */ bool isAlive() const;
00062         /* virtual */ void start(); 
00063         /* virtual */ void stop();
00064 
00065         void setTimeout(F32 d);
00066         void ping();
00067 
00068 private:
00069         LLTimer mTimer;
00070         F32 mTimeout;
00071 };
00072 
00073 class LLWatchdogTimerThread; // Defined in the cpp
00074 class LLWatchdog : public LLSingleton<LLWatchdog>
00075 {
00076 public:
00077         LLWatchdog();
00078         ~LLWatchdog();
00079 
00080         // Add an entry to the watchdog.
00081         void add(LLWatchdogEntry* e);
00082         void remove(LLWatchdogEntry* e);
00083 
00084         void init();
00085         void run();
00086         void cleanup();
00087     
00088 private:
00089         typedef std::set<LLWatchdogEntry*> SuspectsRegistry;
00090         SuspectsRegistry mSuspects;
00091         LLMutex* mSuspectsAccessMutex;
00092         LLWatchdogTimerThread* mTimer;
00093 };
00094 
00095 #endif // LL_LLTHREADWATCHDOG_H

Generated on Fri May 16 08:34:24 2008 for SecondLife by  doxygen 1.5.5