00001
00002 #ifndef TIMER_HH
00003 #define TIMER_HH
00004 #include "rcs_defs.hh"
00005
00006
00007 extern "C"
00008 {
00009 #ifndef NO_STDIO
00010 #include <stdio.h>
00011 #endif
00012 }
00013
00014 #ifdef MSDOS
00015 #ifdef USE_SEMS_FOR_TIMER
00016 #undef USE_SEMS_FOR_TIMER
00017 #endif
00018 #endif
00019
00020 #if USE_SEMS_FOR_TIMER
00021 #include "sem.hh"
00022 #endif
00023
00024
00025 #include "_timer.h"
00026
00027
00028 #ifndef sparcworks
00029 typedef int (*RCS_TIMERFUNC) (void *_arg = NULL);
00030 #else
00031 typedef int (*RCS_TIMERFUNC) (void *_arg);
00032 #endif
00033
00034
00035 typedef void (*RCS_SIGFUNC) (...);
00036
00037 #if (defined (SUN) || defined (LYNX)) && !defined(lynxosVME) && !defined(sunos4CC)
00038
00039
00040 extern int itimer_set (double time, int periodic = 1);
00041
00042
00043 extern void itimer_attach (RCS_SIGFUNC function);
00044
00045
00046 extern void itimer_wait ();
00047
00048 #endif
00049
00050
00051
00052
00053
00054
00055 class RCS_EXPORT RCS_TIMER
00056 {
00057 public:
00058 RCS_TIMER (double timeout, RCS_TIMERFUNC function =
00059 (RCS_TIMERFUNC) NULL, void *arg = NULL);
00060 RCS_TIMER (char *process_name, char *timer_config_file);
00061 RCS_TIMER (double _timeout, char *process_name, char *timer_config_file);
00062
00063
00064 ~RCS_TIMER ();
00065 int wait ();
00066 double load ();
00067
00068 void sync ();
00069 double timeout;
00070
00071 private:
00072 void init (double _timeout, int _id);
00073
00074 void zero_timer ();
00075 void set_timeout (double _timeout);
00076 #if 0
00077 void read_config_file (char *process, char *config_file);
00078 #endif
00079 RCS_TIMERFUNC function;
00080 void *arg;
00081 double last_time;
00082 double start_time;
00083 double idle;
00084 int counts;
00085 int counts_since_real_sleep;
00086 int counts_per_real_sleep;
00087 double time_since_real_sleep;
00088 #ifdef USE_SEMS_FOR_TIMER
00089 RCS_SEMAPHORE **sems;
00090 #endif
00091 int num_sems;
00092 int sem_key;
00093 int id;
00094 int create_sems;
00095 int poller_pid;
00096 double clk_tck_val;
00097 };
00098
00099 #endif