]> git.sur5r.net Git - openldap/blob - include/ldap_pvt_thread.h
The start of a 2.4 branch
[openldap] / include / ldap_pvt_thread.h
1 /* ldap_pvt_thread.h - ldap threads header file */
2 /* $OpenLDAP$ */
3 /* This work is part of OpenLDAP Software <http://www.openldap.org/>.
4  * 
5  * Copyright 1998-2006 The OpenLDAP Foundation.
6  * All rights reserved.
7  *
8  * Redistribution and use in source and binary forms, with or without
9  * modification, are permitted only as authorized by the OpenLDAP
10  * Public License.
11  *
12  * A copy of this license is available in file LICENSE in the
13  * top-level directory of the distribution or, alternatively, at
14  * <http://www.OpenLDAP.org/license.html>.
15  */
16
17 #ifndef _LDAP_PVT_THREAD_H
18 #define _LDAP_PVT_THREAD_H /* libldap_r/ldap_thr_debug.h #undefines this */
19
20 #include "ldap_cdefs.h"
21 #include "ldap_int_thread.h"
22
23 LDAP_BEGIN_DECL
24
25 #ifndef LDAP_PVT_THREAD_H_DONE
26 typedef ldap_int_thread_t                       ldap_pvt_thread_t;
27 #ifdef LDAP_THREAD_DEBUG_WRAP
28 typedef ldap_debug_thread_mutex_t       ldap_pvt_thread_mutex_t;
29 typedef ldap_debug_thread_cond_t        ldap_pvt_thread_cond_t;
30 typedef ldap_debug_thread_rdwr_t        ldap_pvt_thread_rdwr_t;
31 #else
32 typedef ldap_int_thread_mutex_t         ldap_pvt_thread_mutex_t;
33 typedef ldap_int_thread_cond_t          ldap_pvt_thread_cond_t;
34 typedef ldap_int_thread_rdwr_t          ldap_pvt_thread_rdwr_t;
35 #endif
36 #endif /* !LDAP_PVT_THREAD_H_DONE */
37
38 #if 0 && defined(LDAP_DEVEL)
39 /* must also be defined in slapd.h */
40 #define LDAP_PVT_THREAD_POOL_SEM_LOAD_CONTROL
41 #endif
42
43 #define ldap_pvt_thread_equal           ldap_int_thread_equal
44
45 LDAP_F( int )
46 ldap_pvt_thread_initialize LDAP_P(( void ));
47
48 LDAP_F( int )
49 ldap_pvt_thread_destroy LDAP_P(( void ));
50
51 LDAP_F( unsigned int )
52 ldap_pvt_thread_sleep LDAP_P(( unsigned int s ));
53
54 LDAP_F( int )
55 ldap_pvt_thread_get_concurrency LDAP_P(( void ));
56
57 LDAP_F( int )
58 ldap_pvt_thread_set_concurrency LDAP_P(( int ));
59
60 #define LDAP_PVT_THREAD_CREATE_JOINABLE 0
61 #define LDAP_PVT_THREAD_CREATE_DETACHED 1
62
63 #ifndef LDAP_PVT_THREAD_H_DONE
64 #define LDAP_PVT_THREAD_SET_STACK_SIZE
65 #ifndef LDAP_PVT_THREAD_STACK_SIZE
66         /* LARGE stack. Will be twice as large on 64 bit machine. */
67 #define LDAP_PVT_THREAD_STACK_SIZE      ( 1 * 1024 * 1024 * sizeof(void *) )
68 /* May be explicitly defined to zero to disable it */
69 #elif LDAP_PVT_THREAD_STACK_SIZE == 0
70 #undef LDAP_PVT_THREAD_SET_STACK_SIZE
71 #endif
72 #endif /* !LDAP_PVT_THREAD_H_DONE */
73
74 LDAP_F( int )
75 ldap_pvt_thread_create LDAP_P((
76         ldap_pvt_thread_t * thread,
77         int     detach,
78         void *(*start_routine)( void * ),
79         void *arg));
80
81 LDAP_F( void )
82 ldap_pvt_thread_exit LDAP_P(( void *retval ));
83
84 LDAP_F( int )
85 ldap_pvt_thread_join LDAP_P(( ldap_pvt_thread_t thread, void **status ));
86
87 LDAP_F( int )
88 ldap_pvt_thread_kill LDAP_P(( ldap_pvt_thread_t thread, int signo ));
89
90 LDAP_F( int )
91 ldap_pvt_thread_yield LDAP_P(( void ));
92
93 LDAP_F( int )
94 ldap_pvt_thread_cond_init LDAP_P(( ldap_pvt_thread_cond_t *cond ));
95
96 LDAP_F( int )
97 ldap_pvt_thread_cond_destroy LDAP_P(( ldap_pvt_thread_cond_t *cond ));
98
99 LDAP_F( int )
100 ldap_pvt_thread_cond_signal LDAP_P(( ldap_pvt_thread_cond_t *cond ));
101
102 LDAP_F( int )
103 ldap_pvt_thread_cond_broadcast LDAP_P(( ldap_pvt_thread_cond_t *cond ));
104
105 LDAP_F( int )
106 ldap_pvt_thread_cond_wait LDAP_P((
107         ldap_pvt_thread_cond_t *cond,
108         ldap_pvt_thread_mutex_t *mutex ));
109
110 LDAP_F( int )
111 ldap_pvt_thread_mutex_init LDAP_P(( ldap_pvt_thread_mutex_t *mutex ));
112
113 LDAP_F( int )
114 ldap_pvt_thread_mutex_destroy LDAP_P(( ldap_pvt_thread_mutex_t *mutex ));
115
116 LDAP_F( int )
117 ldap_pvt_thread_mutex_lock LDAP_P(( ldap_pvt_thread_mutex_t *mutex ));
118
119 LDAP_F( int )
120 ldap_pvt_thread_mutex_trylock LDAP_P(( ldap_pvt_thread_mutex_t *mutex ));
121
122 LDAP_F( int )
123 ldap_pvt_thread_mutex_unlock LDAP_P(( ldap_pvt_thread_mutex_t *mutex ));
124
125 LDAP_F( ldap_pvt_thread_t )
126 ldap_pvt_thread_self LDAP_P(( void ));
127
128 #ifdef  LDAP_INT_THREAD_ASSERT_MUTEX_OWNER
129 #define LDAP_PVT_THREAD_ASSERT_MUTEX_OWNER LDAP_INT_THREAD_ASSERT_MUTEX_OWNER
130 #else
131 #define LDAP_PVT_THREAD_ASSERT_MUTEX_OWNER(mutex) ((void) 0)
132 #endif
133
134 LDAP_F( int )
135 ldap_pvt_thread_rdwr_init LDAP_P((ldap_pvt_thread_rdwr_t *rdwrp));
136
137 LDAP_F( int )
138 ldap_pvt_thread_rdwr_destroy LDAP_P((ldap_pvt_thread_rdwr_t *rdwrp));
139
140 LDAP_F( int )
141 ldap_pvt_thread_rdwr_rlock LDAP_P((ldap_pvt_thread_rdwr_t *rdwrp));
142
143 LDAP_F( int )
144 ldap_pvt_thread_rdwr_rtrylock LDAP_P((ldap_pvt_thread_rdwr_t *rdwrp));
145
146 LDAP_F( int )
147 ldap_pvt_thread_rdwr_runlock LDAP_P((ldap_pvt_thread_rdwr_t *rdwrp));
148
149 LDAP_F( int )
150 ldap_pvt_thread_rdwr_wlock LDAP_P((ldap_pvt_thread_rdwr_t *rdwrp));
151
152 LDAP_F( int )
153 ldap_pvt_thread_rdwr_wtrylock LDAP_P((ldap_pvt_thread_rdwr_t *rdwrp));
154
155 LDAP_F( int )
156 ldap_pvt_thread_rdwr_wunlock LDAP_P((ldap_pvt_thread_rdwr_t *rdwrp));
157
158 #ifdef LDAP_DEBUG
159 LDAP_F( int )
160 ldap_pvt_thread_rdwr_readers LDAP_P((ldap_pvt_thread_rdwr_t *rdwrp));
161
162 LDAP_F( int )
163 ldap_pvt_thread_rdwr_writers LDAP_P((ldap_pvt_thread_rdwr_t *rdwrp));
164
165 LDAP_F( int )
166 ldap_pvt_thread_rdwr_active LDAP_P((ldap_pvt_thread_rdwr_t *rdwrp));
167 #endif /* LDAP_DEBUG */
168
169 #define LDAP_PVT_THREAD_EINVAL EINVAL
170 #define LDAP_PVT_THREAD_EBUSY EINVAL
171
172 #ifndef LDAP_PVT_THREAD_H_DONE
173 typedef ldap_int_thread_pool_t ldap_pvt_thread_pool_t;
174
175 typedef void * (ldap_pvt_thread_start_t) LDAP_P((void *ctx, void *arg));
176 typedef void (ldap_pvt_thread_pool_keyfree_t) LDAP_P((void *key, void *data));
177 #endif /* !LDAP_PVT_THREAD_H_DONE */
178
179 LDAP_F( int )
180 ldap_pvt_thread_pool_init LDAP_P((
181         ldap_pvt_thread_pool_t *pool_out,
182         int max_threads,
183         int max_pending ));
184
185 LDAP_F( int )
186 ldap_pvt_thread_pool_submit LDAP_P((
187         ldap_pvt_thread_pool_t *pool,
188         ldap_pvt_thread_start_t *start,
189         void *arg ));
190
191 LDAP_F( int )
192 ldap_pvt_thread_pool_maxthreads LDAP_P((
193         ldap_pvt_thread_pool_t *pool,
194         int max_threads ));
195
196 LDAP_F( int )
197 ldap_pvt_thread_pool_backload LDAP_P((
198         ldap_pvt_thread_pool_t *pool ));
199
200 LDAP_F( int )
201 ldap_pvt_thread_pool_pause LDAP_P((
202         ldap_pvt_thread_pool_t *pool ));
203
204 LDAP_F( int )
205 ldap_pvt_thread_pool_resume LDAP_P((
206         ldap_pvt_thread_pool_t *pool ));
207
208 LDAP_F( int )
209 ldap_pvt_thread_pool_destroy LDAP_P((
210         ldap_pvt_thread_pool_t *pool,
211         int run_pending ));
212
213 LDAP_F( int )
214 ldap_pvt_thread_pool_getkey LDAP_P((
215         void *ctx,
216         void *key,
217         void **data,
218         ldap_pvt_thread_pool_keyfree_t **kfree ));
219
220 LDAP_F( int )
221 ldap_pvt_thread_pool_setkey LDAP_P((
222         void *ctx,
223         void *key,
224         void *data,
225         ldap_pvt_thread_pool_keyfree_t *kfree ));
226
227 LDAP_F( void )
228 ldap_pvt_thread_pool_purgekey LDAP_P(( void *key ));
229
230 LDAP_F( void *)
231 ldap_pvt_thread_pool_context LDAP_P(( void ));
232
233 LDAP_F( void )
234 ldap_pvt_thread_pool_context_reset LDAP_P(( void *key ));
235
236 LDAP_END_DECL
237
238 #define LDAP_PVT_THREAD_H_DONE
239 #endif /* _LDAP_THREAD_H */