~drizzle-trunk/drizzle/development

« back to all changes in this revision

Viewing changes to mysys/thr_alarm.h

  • Committer: Brian Aker
  • Date: 2009-02-10 08:46:50 UTC
  • Revision ID: brian@tangent.org-20090210084650-msdv9hu2mzil8cbb
Remove thr_alarm

Show diffs side-by-side

added added

removed removed

Lines of Context:
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
 
 
21
 
#include <signal.h>
22
 
 
23
 
#ifdef  __cplusplus
24
 
extern "C" {
25
 
#endif
26
 
 
27
 
#ifndef USE_ALARM_THREAD
28
 
#define USE_ONE_SIGNAL_HAND             /* One must call process_alarm */
29
 
#endif
30
 
#ifdef HAVE_rts_threads
31
 
#undef USE_ONE_SIGNAL_HAND
32
 
#define USE_ALARM_THREAD
33
 
#define THR_SERVER_ALARM SIGUSR1
34
 
#else
35
 
#define THR_SERVER_ALARM SIGALRM
36
 
#endif
37
 
 
38
 
typedef struct st_alarm_info
39
 
{
40
 
  uint32_t next_alarm_time;
41
 
  uint32_t active_alarms;
42
 
  uint32_t max_used_alarms;
43
 
} ALARM_INFO;
44
 
 
45
 
void thr_alarm_info(ALARM_INFO *info);
46
 
 
47
 
#if defined(DONT_USE_THR_ALARM)
48
 
 
49
 
#define USE_ALARM_THREAD
50
 
#undef USE_ONE_SIGNAL_HAND
51
 
 
52
 
typedef bool thr_alarm_t;
53
 
typedef bool ALARM;
54
 
 
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)
65
 
 
66
 
#else
67
 
 
68
 
typedef unsigned int thr_alarm_entry;
69
 
#define thr_got_alarm(thr_alarm) (**(thr_alarm))
70
 
 
71
 
typedef thr_alarm_entry* thr_alarm_t;
72
 
 
73
 
typedef struct st_alarm {
74
 
  time_t expire_time;
75
 
  thr_alarm_entry alarmed;              /* set when alarm is due */
76
 
  pthread_t thread;
77
 
  my_thread_id thread_id;
78
 
  bool malloced;
79
 
} ALARM;
80
 
 
81
 
extern uint32_t thr_client_alarm;
82
 
extern pthread_t alarm_thread;
83
 
 
84
 
int compare_uint32_t(void *unused, unsigned char *a_ptr,unsigned char* b_ptr);
85
 
void thread_alarm(int sig);
86
 
 
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);
96
 
#ifndef thr_got_alarm
97
 
bool thr_got_alarm(thr_alarm_t *alrm);
98
 
#endif
99
 
 
100
 
 
101
 
#endif /* DONT_USE_THR_ALARM */
102
 
 
103
 
#ifdef  __cplusplus
104
 
}
105
 
#endif /* __cplusplus */
106
 
#endif /* _thr_alarm_h */