00001
00002
00003 #ifndef __J2K__Timer_HPP__
00004 #define __J2K__Timer_HPP__
00005
00006 #include <j2k/Fred/Standard.hpp>
00007 #include <j2k/Fred/Error/JErrorController.hpp>
00008
00009 #include <unistd.h>
00010 #include <errno.h>
00011 #include <pthread.h>
00012 #include <signal.h>
00013 #include <sys/time.h>
00014
00015 #if !defined( linux )
00016 #include <sys/siginfo.h>
00017 #endif
00018
00019
00020 #define TimerSignal SIGUSR1
00021
00022 class Timer;
00023
00024
00025 Timer* theTimer = NULL;
00026
00027 class Timer {
00028 public:
00029
00030
00031 Timer( ULONG nsec, ULONG sec = 0 );
00032
00033 inline void start();
00034
00035
00036 static void wrapper( int signo )
00037 {
00038 theTimer->timedRun( signo );
00039 }
00040
00041
00042 virtual void timedRun( int signo ) = 0;
00043
00044 private:
00045 clockid_t timerid;
00046 struct sigevent event;
00047 struct itimerspec t;
00048 };
00049
00050 #endif