Eneboo - Documentación para desarrolladores
src/libmysql_macosx/include/thr_alarm.h
Ir a la documentación de este archivo.
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 #elif defined(__EMX__) || defined(OS2)
00077 
00078 typedef struct st_thr_alarm_entry
00079 {
00080   uint crono;
00081   uint event;
00082 } thr_alarm_entry;
00083 
00084 #else /* System with posix threads */
00085 
00086 typedef int thr_alarm_entry;
00087 
00088 #define thr_got_alarm(thr_alarm) (**(thr_alarm))
00089 
00090 #endif /* __WIN__ */
00091 
00092 typedef thr_alarm_entry* thr_alarm_t;
00093 
00094 typedef struct st_alarm {
00095   ulong expire_time;
00096   thr_alarm_entry alarmed;              /* set when alarm is due */
00097   pthread_t thread;
00098   my_bool malloced;
00099 } ALARM;
00100 
00101 #define thr_alarm_init(A) (*(A))=0
00102 #define thr_alarm_in_use(A) (*(A)!= 0)
00103 void init_thr_alarm(uint max_alarm);
00104 void resize_thr_alarm(uint max_alarms);
00105 my_bool thr_alarm(thr_alarm_t *alarmed, uint sec, ALARM *buff);
00106 void thr_alarm_kill(pthread_t thread_id);
00107 void thr_end_alarm(thr_alarm_t *alarmed);
00108 void end_thr_alarm(my_bool free_structures);
00109 sig_handler process_alarm(int);
00110 #ifndef thr_got_alarm
00111 bool thr_got_alarm(thr_alarm_t *alrm);
00112 #endif
00113 
00114 
00115 #endif /* DONT_USE_THR_ALARM */
00116 
00117 #ifdef  __cplusplus
00118 }
00119 #endif /* __cplusplus */
00120 #endif /* _thr_alarm_h */
 Todo Clases Namespaces Archivos Funciones Variables 'typedefs' Enumeraciones Valores de enumeraciones Propiedades Amigas 'defines'