Main Page   Packages   Namespace List   Class Hierarchy   Alphabetical List   Compound List   File List   Compound Members   File Members   Search  

C:/temp/src/j2k/QNX4/TimerThread.hpp

Go to the documentation of this file.
00001 #ifndef __J2K__TimerThread_HPP__
00002 #define __J2K__TimerThread_HPP__
00003 
00004 #include <j2k/Fred/Basic.hpp>
00005 #include <j2k/Fred/Boolean.hpp>
00006 #include <j2k/Fred/StdTypes.hpp>
00007 
00008 #include <j2k/Fred/QNX/MsgThread.hpp>
00009 
00010 #include <time.h>
00011 #include <sys/proxy.h>
00012 #include <signal.h>
00013    
00014 // Default Timer Arguments
00015 #define  DEFAULT_TIMER_STACK    4096
00016 #define  DEFAULT_TIMER_ALGO     SCHED_RR
00017 #define  DEFAULT_TIMER_PRIO     19
00018 #define  DEFAULT_TIMER_PERIOD   120000000L
00019 
00020 // The time period is in nanosec, which is 120 ms by default
00021 
00022 class TimerThread : public MsgThread {
00023 
00024 public:
00025 
00026   TimerThread();
00027  
00028   virtual ~TimerThread();
00029 
00030   void start( timespec& period = DEFAULT_TIMER_PERIOD,
00031                    int  algo   = DEFAULT_TIMER_ALGO,
00032                    int  prio   = DEFAULT_TIMER_PRIO,
00033                 size_t  stack  = DEFAULT_TIMER_STACK  );
00034 
00035   void stop();
00036 
00037   // timer query functions
00038   int getTime( timerspec& output ) {
00039     return timer_gettime( Timer_ID, &output);
00040   }
00041 
00042   timer_t  getTimerID() {
00043     return Timer_ID;
00044   }
00045 
00046   // Timer class Users should override this function
00047   virtual void tick() = 0;
00048 
00049 protected:
00050   timer_t  Timer_ID;
00051   pid_t    Proxy_ID;
00052 
00053   static const int defaultMsg;
00054 
00055   // override
00056   virtual int message_filter( int m, char* data, pid_t mpid );
00057   virtual int MsgSort( void* msg, void* ptrThis, pid_t rPid, void* p );
00058 
00059 };
00060 
00061 #endif 
00062 

Generated on Sun Oct 14 18:46:42 2001 for Standard J2K Library by doxygen1.2.11.1 written by Dimitri van Heesch, © 1997-2001