00001 #ifndef LOOP_THREAD_OBJ_H 00002 #define LOOP_THREAD_OBJ_H 00003 #include <time.h> 00004 #include "engine/thread_obj.h" 00005 #include "engine/mutex.h" 00006 00011 class FastLoopThreadObj : public ThreadObj 00012 { 00013 protected: 00015 virtual void Loop() = 0; 00016 00017 public: 00018 FastLoopThreadObj(const std::string); 00019 virtual ~FastLoopThreadObj(); 00020 virtual void Main(); 00021 00023 virtual void OnStart() {} 00025 virtual void OnStop() {} 00026 }; 00027 00031 class LoopThreadObj : public FastLoopThreadObj 00032 { 00033 unsigned int sleep_time; 00034 time_t last_wake; 00035 Mutex sleep_mutex; 00036 00037 protected: 00039 virtual void Loop() = 0; 00040 00049 void WakeUp(); 00050 00051 public: 00052 LoopThreadObj(const std::string); 00053 virtual ~LoopThreadObj(); 00054 void Main(); 00055 00058 unsigned int GetSleepTime(); 00059 }; 00060 00061 #endif
1.5.8