00001 /* Copyright (C) 2000 MySQL AB 00002 00003 This program is free software; you can redistribute it and/or modify 00004 it under the terms of the GNU General Public License as published by 00005 the Free Software Foundation; either version 2 of the License, or 00006 (at your option) any later version. 00007 00008 This program is distributed in the hope that it will be useful, 00009 but WITHOUT ANY WARRANTY; without even the implied warranty of 00010 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 00011 GNU General Public License for more details. 00012 00013 You should have received a copy of the GNU General Public License 00014 along with this program; if not, write to the Free Software 00015 Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA */ 00016 00017 /* Prototypes when using thr_alarm library functions */ 00018 00019 #ifndef _thr_alarm_h 00020 #define _thr_alarm_h 00021 #ifdef __cplusplus 00022 extern "C" { 00023 #endif 00024 00025 #ifndef USE_ALARM_THREAD 00026 #define USE_ONE_SIGNAL_HAND /* One must call process_alarm */ 00027 #endif 00028 #ifdef HAVE_LINUXTHREADS 00029 #define THR_CLIENT_ALARM SIGALRM 00030 #else 00031 #define THR_CLIENT_ALARM SIGUSR1 00032 #endif 00033 #ifdef HAVE_rts_threads 00034 #undef USE_ONE_SIGNAL_HAND 00035 #define USE_ALARM_THREAD 00036 #define THR_SERVER_ALARM SIGUSR1 00037 #else 00038 #define THR_SERVER_ALARM SIGALRM 00039 #endif 00040 00041 typedef struct st_alarm_info 00042 { 00043 ulong next_alarm_time; 00044 uint active_alarms; 00045 uint max_used_alarms; 00046 } ALARM_INFO; 00047 00048 void thr_alarm_info(ALARM_INFO *info); 00049 00050 #if defined(DONT_USE_THR_ALARM) || !defined(THREAD) 00051 00052 #define USE_ALARM_THREAD 00053 #undef USE_ONE_SIGNAL_HAND 00054 00055 typedef my_bool thr_alarm_t; 00056 typedef my_bool ALARM; 00057 00058 #define thr_alarm_init(A) (*(A))=0 00059 #define thr_alarm_in_use(A) (*(A) != 0) 00060 #define thr_end_alarm(A) 00061 #define thr_alarm(A,B,C) ((*(A)=1)-1) 00062 /* The following should maybe be (*(A)) */ 00063 #define thr_got_alarm(A) 0 00064 #define init_thr_alarm(A) 00065 #define thr_alarm_kill(A) 00066 #define resize_thr_alarm(N) 00067 #define end_thr_alarm(A) 00068 00069 #else 00070 #if defined(__WIN__) 00071 typedef struct st_thr_alarm_entry 00072 { 00073 rf_SetTimer crono; 00074 } thr_alarm_entry; 00075 00076 #else /* System with posix threads */ 00077 00078 typedef int thr_alarm_entry; 00079 00080 #define thr_got_alarm(thr_alarm) (**(thr_alarm)) 00081 00082 #endif /* __WIN__ */ 00083 00084 typedef thr_alarm_entry* thr_alarm_t; 00085 00086 typedef struct st_alarm { 00087 ulong expire_time; 00088 thr_alarm_entry alarmed; /* set when alarm is due */ 00089 pthread_t thread; 00090 my_bool malloced; 00091 } ALARM; 00092 00093 #define thr_alarm_init(A) (*(A))=0 00094 #define thr_alarm_in_use(A) (*(A)!= 0) 00095 void init_thr_alarm(uint max_alarm); 00096 void resize_thr_alarm(uint max_alarms); 00097 my_bool thr_alarm(thr_alarm_t *alarmed, uint sec, ALARM *buff); 00098 void thr_alarm_kill(pthread_t thread_id); 00099 void thr_end_alarm(thr_alarm_t *alarmed); 00100 void end_thr_alarm(my_bool free_structures); 00101 sig_handler process_alarm(int); 00102 #ifndef thr_got_alarm 00103 bool thr_got_alarm(thr_alarm_t *alrm); 00104 #endif 00105 00106 00107 #endif /* DONT_USE_THR_ALARM */ 00108 00109 #ifdef __cplusplus 00110 } 00111 #endif /* __cplusplus */ 00112 #endif /* _thr_alarm_h */
1.4.7

