1
by brian
clean slate |
1 |
/* Copyright (C) 2000 MySQL AB
|
2 |
||
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.
|
|
6 |
||
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.
|
|
11 |
||
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 */
|
|
15 |
||
16 |
/* Prototypes when using thr_alarm library functions */
|
|
17 |
||
18 |
#ifndef _thr_alarm_h
|
|
19 |
#define _thr_alarm_h
|
|
20 |
#ifdef __cplusplus
|
|
21 |
extern "C" { |
|
22 |
#endif
|
|
23 |
||
24 |
#ifndef USE_ALARM_THREAD
|
|
25 |
#define USE_ONE_SIGNAL_HAND /* One must call process_alarm */ |
|
26 |
#endif
|
|
27 |
#ifdef HAVE_rts_threads
|
|
28 |
#undef USE_ONE_SIGNAL_HAND
|
|
29 |
#define USE_ALARM_THREAD
|
|
30 |
#define THR_SERVER_ALARM SIGUSR1
|
|
31 |
#else
|
|
32 |
#define THR_SERVER_ALARM SIGALRM
|
|
33 |
#endif
|
|
34 |
||
35 |
typedef struct st_alarm_info |
|
36 |
{
|
|
298
by Brian Aker
ulong conversion. |
37 |
uint32_t next_alarm_time; |
482
by Brian Aker
Remove uint. |
38 |
uint32_t active_alarms; |
39 |
uint32_t max_used_alarms; |
|
1
by brian
clean slate |
40 |
} ALARM_INFO; |
41 |
||
42 |
void thr_alarm_info(ALARM_INFO *info); |
|
43 |
||
28.1.35
by Monty Taylor
Removed all references to THREAD. |
44 |
#if defined(DONT_USE_THR_ALARM)
|
1
by brian
clean slate |
45 |
|
46 |
#define USE_ALARM_THREAD
|
|
47 |
#undef USE_ONE_SIGNAL_HAND
|
|
48 |
||
146
by Brian Aker
my_bool cleanup. |
49 |
typedef bool thr_alarm_t; |
50 |
typedef bool ALARM; |
|
1
by brian
clean slate |
51 |
|
52 |
#define thr_alarm_init(A) (*(A))=0
|
|
53 |
#define thr_alarm_in_use(A) (*(A) != 0)
|
|
54 |
#define thr_end_alarm(A)
|
|
55 |
#define thr_alarm(A,B,C) ((*(A)=1)-1)
|
|
56 |
/* The following should maybe be (*(A)) */
|
|
57 |
#define thr_got_alarm(A) 0
|
|
58 |
#define init_thr_alarm(A)
|
|
59 |
#define thr_alarm_kill(A)
|
|
60 |
#define resize_thr_alarm(N)
|
|
61 |
#define end_thr_alarm(A)
|
|
62 |
||
63 |
#else
|
|
64 |
||
65 |
typedef int thr_alarm_entry; |
|
66 |
#define thr_got_alarm(thr_alarm) (**(thr_alarm))
|
|
67 |
||
68 |
typedef thr_alarm_entry* thr_alarm_t; |
|
69 |
||
70 |
typedef struct st_alarm { |
|
298
by Brian Aker
ulong conversion. |
71 |
uint32_t expire_time; |
1
by brian
clean slate |
72 |
thr_alarm_entry alarmed; /* set when alarm is due */ |
73 |
pthread_t thread; |
|
74 |
my_thread_id thread_id; |
|
146
by Brian Aker
my_bool cleanup. |
75 |
bool malloced; |
1
by brian
clean slate |
76 |
} ALARM; |
77 |
||
482
by Brian Aker
Remove uint. |
78 |
extern uint32_t thr_client_alarm; |
1
by brian
clean slate |
79 |
extern pthread_t alarm_thread; |
80 |
||
81 |
#define thr_alarm_init(A) (*(A))=0
|
|
82 |
#define thr_alarm_in_use(A) (*(A)!= 0)
|
|
482
by Brian Aker
Remove uint. |
83 |
void init_thr_alarm(uint32_t max_alarm); |
84 |
void resize_thr_alarm(uint32_t max_alarms); |
|
85 |
bool thr_alarm(thr_alarm_t *alarmed, uint32_t sec, ALARM *buff); |
|
1
by brian
clean slate |
86 |
void thr_alarm_kill(my_thread_id thread_id); |
87 |
void thr_end_alarm(thr_alarm_t *alarmed); |
|
146
by Brian Aker
my_bool cleanup. |
88 |
void end_thr_alarm(bool free_structures); |
454
by Monty Taylor
Removed RETSIGHANDLER to sig_handler define. |
89 |
RETSIGTYPE process_alarm(int); |
1
by brian
clean slate |
90 |
#ifndef thr_got_alarm
|
146
by Brian Aker
my_bool cleanup. |
91 |
bool thr_got_alarm(thr_alarm_t *alrm); |
1
by brian
clean slate |
92 |
#endif
|
93 |
||
94 |
||
95 |
#endif /* DONT_USE_THR_ALARM */ |
|
96 |
||
97 |
#ifdef __cplusplus
|
|
98 |
}
|
|
99 |
#endif /* __cplusplus */ |
|
100 |
#endif /* _thr_alarm_h */ |