/External/Mysql-5.0/include/thr_alarm.h

http://awoe.googlecode.com/ · C++ Header · 110 lines · 73 code · 21 blank · 16 comment · 2 complexity · 072e32d07690a2a5552006cbae2d08be MD5 · raw file

  1. /* Copyright (C) 2000 MySQL AB
  2. This program is free software; you can redistribute it and/or modify
  3. it under the terms of the GNU General Public License as published by
  4. the Free Software Foundation; version 2 of the License.
  5. This program is distributed in the hope that it will be useful,
  6. but WITHOUT ANY WARRANTY; without even the implied warranty of
  7. MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
  8. GNU General Public License for more details.
  9. You should have received a copy of the GNU General Public License
  10. along with this program; if not, write to the Free Software
  11. Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA */
  12. /* Prototypes when using thr_alarm library functions */
  13. #ifndef _thr_alarm_h
  14. #define _thr_alarm_h
  15. #ifdef __cplusplus
  16. extern "C" {
  17. #endif
  18. #ifndef USE_ALARM_THREAD
  19. #define USE_ONE_SIGNAL_HAND /* One must call process_alarm */
  20. #endif
  21. #ifdef HAVE_rts_threads
  22. #undef USE_ONE_SIGNAL_HAND
  23. #define USE_ALARM_THREAD
  24. #define THR_SERVER_ALARM SIGUSR1
  25. #else
  26. #define THR_SERVER_ALARM SIGALRM
  27. #endif
  28. typedef struct st_alarm_info
  29. {
  30. ulong next_alarm_time;
  31. uint active_alarms;
  32. uint max_used_alarms;
  33. } ALARM_INFO;
  34. void thr_alarm_info(ALARM_INFO *info);
  35. #if defined(DONT_USE_THR_ALARM) || !defined(THREAD)
  36. #define USE_ALARM_THREAD
  37. #undef USE_ONE_SIGNAL_HAND
  38. typedef my_bool thr_alarm_t;
  39. typedef my_bool ALARM;
  40. #define thr_alarm_init(A) (*(A))=0
  41. #define thr_alarm_in_use(A) (*(A) != 0)
  42. #define thr_end_alarm(A)
  43. #define thr_alarm(A,B,C) ((*(A)=1)-1)
  44. /* The following should maybe be (*(A)) */
  45. #define thr_got_alarm(A) 0
  46. #define init_thr_alarm(A)
  47. #define thr_alarm_kill(A)
  48. #define resize_thr_alarm(N)
  49. #define end_thr_alarm(A)
  50. #else
  51. #if defined(__WIN__)
  52. typedef struct st_thr_alarm_entry
  53. {
  54. rf_SetTimer crono;
  55. } thr_alarm_entry;
  56. #else /* System with posix threads */
  57. typedef int thr_alarm_entry;
  58. #define thr_got_alarm(thr_alarm) (**(thr_alarm))
  59. #endif /* __WIN__ */
  60. typedef thr_alarm_entry* thr_alarm_t;
  61. typedef struct st_alarm {
  62. ulong expire_time;
  63. thr_alarm_entry alarmed; /* set when alarm is due */
  64. pthread_t thread;
  65. my_thread_id thread_id;
  66. my_bool malloced;
  67. } ALARM;
  68. extern uint thr_client_alarm;
  69. extern pthread_t alarm_thread;
  70. #define thr_alarm_init(A) (*(A))=0
  71. #define thr_alarm_in_use(A) (*(A)!= 0)
  72. void init_thr_alarm(uint max_alarm);
  73. void resize_thr_alarm(uint max_alarms);
  74. my_bool thr_alarm(thr_alarm_t *alarmed, uint sec, ALARM *buff);
  75. void thr_alarm_kill(my_thread_id thread_id);
  76. void thr_end_alarm(thr_alarm_t *alarmed);
  77. void end_thr_alarm(my_bool free_structures);
  78. sig_handler process_alarm(int);
  79. #ifndef thr_got_alarm
  80. my_bool thr_got_alarm(thr_alarm_t *alrm);
  81. #endif
  82. #endif /* DONT_USE_THR_ALARM */
  83. #ifdef __cplusplus
  84. }
  85. #endif /* __cplusplus */
  86. #endif /* _thr_alarm_h */