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

TimerSignal Class Reference

#include <TimerSignal.hpp>

Inheritance diagram for TimerSignal::

TFTP_Timeout TimerTest TimerTest Timing List of all members.

Public Methods

 TimerSignal (ULONG nsec=Period_500_ms, ULONG sec=0)
virtual __inline void start ()
virtual __inline void stop ()
void set (ULONG nsec=Period_500_ms, ULONG sec=0)

Protected Methods

virtual void tick (int signo)=0

Static Protected Methods

void wrapper (int signo)

Static Protected Attributes

TimerSignal * theTimer = NULL

Private Attributes

timer_t timer_id
sigevent event
itimerspec t

Constructor & Destructor Documentation

TimerSignal::TimerSignal ULONG    nsec = Period_500_ms,
ULONG    sec = 0
 

Definition at line 10 of file TimerSignal.cpp.

00011 {
00012 /*
00013   if ( theTimer != NULL ) {
00014     delete theTimer;
00015   }
00016 
00017   theTimer = this;
00018 
00019   memset( &event, 0, sizeof( event ) );
00020 */
00021 
00022   // sched_get_priority_max( SCHED_RR ) == 63
00023 
00024   event.sigev_priority = getprio( 0 ); // fixprio( 20 );
00025 
00026   event.sigev_notify = SIGEV_SIGNAL;
00027   event.sigev_signo  = TimerSignalEvent;
00028 
00029 //  memset( &t, 0, sizeof( t ) );
00030 
00031   // create the timer, binding it to the event
00032 
00033   if ( timer_create( CLOCK_REALTIME, &event, &timer_id ) == -1 )
00034   {
00035      MC_OnError( errno, Error, "while creating a timer." )
00036   }
00037 
00038   struct sigaction act;
00039   sigset_t set_event;
00040 
00041   sigemptyset( &set_event );
00042   sigaddset(   &set_event, TimerSignalEvent );
00043 
00044   // Define a handler for TimerSignalEvent
00045   act.sa_flags   = 0;
00046   act.sa_mask    = set_event;
00047   act.sa_handler = wrapper;
00048 
00049   sigaction( TimerSignalEvent, &act, NULL );
00050 
00051   set( nsec, sec );
00052 }


Member Function Documentation

void TimerSignal::set ULONG    nsec = Period_500_ms,
ULONG    sec = 0
 

Definition at line 55 of file TimerSignal.cpp.

Referenced by TimerSignal(), and stop().

00056 {
00057   t.it_value.tv_nsec    = nsec;
00058   t.it_interval.tv_nsec = nsec;
00059 
00060   t.it_value.tv_sec     = sec;
00061   t.it_interval.tv_sec  = sec;
00062 
00063   timer_settime( timer_id, 0, &t, NULL );
00064 }

void TimerSignal::start   [inline, virtual]
 

Reimplemented in Timing, and TimerTest.

Definition at line 4 of file TimerSignal.inl.

Referenced by TimerTest::start(), theTimer(), and Timer::theTimer().

00005 {
00006   timer_settime( timer_id, 0, &t, NULL );
00007 }

void TimerSignal::stop   [inline, virtual]
 

Definition at line 9 of file TimerSignal.inl.

00010 {
00011   set( 0, 0 );
00012 }

virtual void TimerSignal::tick int    signo [protected, pure virtual]
 

Reimplemented in TimerTest.

Referenced by wrapper(), and Timer::wrapper().

void TimerSignal::wrapper int    signo [inline, static, protected]
 

Definition at line 65 of file TimerSignal.hpp.

00066   {
00067     assert( signo == TimerSignalEvent );
00068     theTimer->tick( signo ); 
00069   }


Member Data Documentation

struct sigevent TimerSignal::event [private]
 

Definition at line 77 of file TimerSignal.hpp.

struct itimerspec TimerSignal::t [private]
 

Definition at line 78 of file TimerSignal.hpp.

TimerSignal * TimerSignal::theTimer = NULL [static, protected]
 

Definition at line 7 of file TimerSignal.cpp.

timer_t TimerSignal::timer_id [private]
 

Definition at line 76 of file TimerSignal.hpp.


The documentation for this class was generated from the following files:
Generated on Sun Oct 14 18:50:18 2001 for Standard J2K Library by doxygen1.2.11.1 written by Dimitri van Heesch, © 1997-2001