Eneboo - Documentación para desarrolladores
src/libmysql_std/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; version 2 of the License.
00006 
00007    This program is distributed in the hope that it will be useful,
00008    but WITHOUT ANY WARRANTY; without even the implied warranty of
00009    MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
00010    GNU General Public License for more details.
00011 
00012    You should have received a copy of the GNU General Public License
00013    along with this program; if not, write to the Free Software
00014    Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA  02111-1307  USA */
00015 
00016 /* Prototypes when using thr_alarm library functions */
00017 
00018 #ifndef _thr_alarm_h
00019 #define _thr_alarm_h
00020 #ifdef  __cplusplus
00021 extern "C" {
00022 #endif
00023 
00024 #ifndef USE_ALARM_THREAD
00025 #define USE_ONE_SIGNAL_HAND             /* One must call process_alarm */
00026 #endif
00027 #ifdef HAVE_rts_threads
00028 #undef USE_ONE_SIGNAL_HAND
00029 #define USE_ALARM_THREAD
00030 #define THR_SERVER_ALARM SIGUSR1
00031 #else
00032 #define THR_SERVER_ALARM SIGALRM
00033 #endif
00034 
00035 typedef struct st_alarm_info
00036 {
00037   ulong next_alarm_time;
00038   uint active_alarms;
00039   uint max_used_alarms;
00040 } ALARM_INFO;
00041 
00042 void thr_alarm_info(ALARM_INFO *info);
00043 
00044 #if defined(DONT_USE_THR_ALARM) || !defined(THREAD)
00045 
00046 #define USE_ALARM_THREAD
00047 #undef USE_ONE_SIGNAL_HAND
00048 
00049 typedef my_bool thr_alarm_t;
00050 typedef my_bool ALARM;
00051 
00052 #define thr_alarm_init(A) (*(A))=0
00053 #define thr_alarm_in_use(A) (*(A) != 0)
00054 #define thr_end_alarm(A)
00055 #define thr_alarm(A,B,C) ((*(A)=1)-1)
00056 /* The following should maybe be (*(A)) */
00057 #define thr_got_alarm(A) 0
00058 #define init_thr_alarm(A)
00059 #define thr_alarm_kill(A)
00060 #define resize_thr_alarm(N)
00061 #define end_thr_alarm(A)
00062 
00063 #else
00064 #if defined(__WIN__)
00065 typedef struct st_thr_alarm_entry
00066 {
00067   rf_SetTimer crono;
00068 } thr_alarm_entry;
00069 
00070 #elif defined(__EMX__) || defined(OS2)
00071 
00072 typedef struct st_thr_alarm_entry
00073 {
00074   uint crono;
00075   uint event;
00076 } thr_alarm_entry;
00077 
00078 #else /* System with posix threads */
00079 
00080 typedef int thr_alarm_entry;
00081 
00082 #define thr_got_alarm(thr_alarm) (**(thr_alarm))
00083 
00084 #endif /* __WIN__ */
00085 
00086 typedef thr_alarm_entry* thr_alarm_t;
00087 
00088 typedef struct st_alarm {
00089   ulong expire_time;
00090   thr_alarm_entry alarmed;              /* set when alarm is due */
00091   pthread_t thread;
00092   my_bool malloced;
00093 } ALARM;
00094 
00095 extern uint thr_client_alarm;
00096 extern pthread_t alarm_thread;
00097 
00098 #define thr_alarm_init(A) (*(A))=0
00099 #define thr_alarm_in_use(A) (*(A)!= 0)
00100 void init_thr_alarm(uint max_alarm);
00101 void resize_thr_alarm(uint max_alarms);
00102 my_bool thr_alarm(thr_alarm_t *alarmed, uint sec, ALARM *buff);
00103 void thr_alarm_kill(pthread_t thread_id);
00104 void thr_end_alarm(thr_alarm_t *alarmed);
00105 void end_thr_alarm(my_bool free_structures);
00106 sig_handler process_alarm(int);
00107 #ifndef thr_got_alarm
00108 bool thr_got_alarm(thr_alarm_t *alrm);
00109 #endif
00110 
00111 
00112 #endif /* DONT_USE_THR_ALARM */
00113 
00114 #ifdef  __cplusplus
00115 }
00116 #endif /* __cplusplus */
00117 #endif /* _thr_alarm_h */
 Todo Clases Namespaces Archivos Funciones Variables 'typedefs' Enumeraciones Valores de enumeraciones Propiedades Amigas 'defines'