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

C:/temp/src/j2k/nto/bak2/TimerTest.cpp

Go to the documentation of this file.
00001 #ifndef __J2K__TimerTest_CPP__
00002 #define __J2K__TimerTest_CPP__
00003 
00004 #include <j2k/nto/TimerSignal.hpp>
00005 #include <j2k/nto/Basic_PThread.hpp>
00006 #include <j2k/nto/fixprio.hpp>
00007 
00008 
00009 // 200 ms
00010 #define WAITING  200000000
00011 
00012 class TimerTest : public Timer 
00013 {
00014 public:
00015 
00016  TimerTest( ULONG clk = WAITING )
00017   : Timer( clk ), loop( 0 ), avg( 0 ) { }
00018 
00019  virtual void tick( int signo )
00020  {
00021     if (avg < 1 ) {
00022       avg = loop;
00023     } else {
00024       avg = ( avg + loop ) / 2;
00025     }
00026 
00027     printf( "Enter handler with signal %d/%d [%d/%d].\n", 
00028              signo, TimerSignalEvent, loop, avg );
00029 
00030     loop = 0;
00031     printf( "End signal handler.\n" );
00032     fflush( stdout );
00033  }
00034 
00035  virtual void start() 
00036  {
00037    printf( "Timer started.\n" );
00038    fflush( stdout );
00039 
00040    Timer::start();
00041  }
00042 
00043   size_t loop;
00044   size_t avg;
00045 };
00046 
00047 TimerTest tt( WAITING );
00048 
00049 int main() {
00050   tt.start();
00051 
00052   for(;;) {  // Infinite loop
00053     tt.loop++;
00054   }
00055 
00056   return 0;
00057 }
00058 
00059 #endif
00060 

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