1
/* Copyright (C) 2000 MySQL AB
3
This program is free software; you can redistribute it and/or modify
4
it under the terms of the GNU General Public License as published by
5
the Free Software Foundation; version 2 of the License.
7
This program is distributed in the hope that it will be useful,
8
but WITHOUT ANY WARRANTY; without even the implied warranty of
9
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
10
GNU General Public License for more details.
12
You should have received a copy of the GNU General Public License
13
along with this program; if not, write to the Free Software
14
Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA */
16
/* Prototypes when using thr_alarm library functions */
27
#ifndef USE_ALARM_THREAD
28
#define USE_ONE_SIGNAL_HAND /* One must call process_alarm */
30
#ifdef HAVE_rts_threads
31
#undef USE_ONE_SIGNAL_HAND
32
#define USE_ALARM_THREAD
33
#define THR_SERVER_ALARM SIGUSR1
35
#define THR_SERVER_ALARM SIGALRM
38
typedef struct st_alarm_info
40
uint32_t next_alarm_time;
41
uint32_t active_alarms;
42
uint32_t max_used_alarms;
45
void thr_alarm_info(ALARM_INFO *info);
47
#if defined(DONT_USE_THR_ALARM)
49
#define USE_ALARM_THREAD
50
#undef USE_ONE_SIGNAL_HAND
52
typedef bool thr_alarm_t;
55
#define thr_alarm_init(A) (*(A))=0
56
#define thr_alarm_in_use(A) (*(A) != 0)
57
#define thr_end_alarm(A)
58
#define thr_alarm(A,B,C) ((*(A)=1)-1)
59
/* The following should maybe be (*(A)) */
60
#define thr_got_alarm(A) 0
61
#define init_thr_alarm(A)
62
#define thr_alarm_kill(A)
63
#define resize_thr_alarm(N)
64
#define end_thr_alarm(A)
68
typedef unsigned int thr_alarm_entry;
69
#define thr_got_alarm(thr_alarm) (**(thr_alarm))
71
typedef thr_alarm_entry* thr_alarm_t;
73
typedef struct st_alarm {
75
thr_alarm_entry alarmed; /* set when alarm is due */
77
my_thread_id thread_id;
81
extern uint32_t thr_client_alarm;
82
extern pthread_t alarm_thread;
84
int compare_uint32_t(void *unused, unsigned char *a_ptr,unsigned char* b_ptr);
85
void thread_alarm(int sig);
87
#define thr_alarm_init(A) (*(A))=0
88
#define thr_alarm_in_use(A) (*(A)!= 0)
89
void init_thr_alarm(uint32_t max_alarm);
90
void resize_thr_alarm(uint32_t max_alarms);
91
bool thr_alarm(thr_alarm_t *alarmed, uint32_t sec, ALARM *buff);
92
void thr_alarm_kill(my_thread_id thread_id);
93
void thr_end_alarm(thr_alarm_t *alarmed);
94
void end_thr_alarm(bool free_structures);
95
void process_alarm(int);
97
bool thr_got_alarm(thr_alarm_t *alrm);
101
#endif /* DONT_USE_THR_ALARM */
105
#endif /* __cplusplus */
106
#endif /* _thr_alarm_h */