00001 #ifndef _Q_TIMER_DISPATCHER_HH_
00002 #define _Q_TIMER_DISPATCHER_HH_
00003
00004 #include <pthread.h>
00005
00006 #include <sys/types.h>
00007 #include <event.h>
00008
00009 #include "QError.hh"
00010
00011 class QTimerDispatcher
00012 {
00013 public:
00014 static QTimerDispatcher& GetInstance();
00015
00016 ~QTimerDispatcher();
00017
00018 void AddTimer();
00019 void ExecuteThread();
00020
00021 bool HasError() const;
00022 void SetError(const QError& err);
00023 const QError& GetError() const;
00024
00025 private:
00026 QTimerDispatcher();
00027 static void* ThreadEntryPoint(void* ptr);
00028
00029 pthread_t fThread;
00030 void* fEvBase;
00031 QError fError;
00032 static pthread_mutex_t fThreadMutex;
00033
00034
00035 };
00036 #endif