Sync usage with man page.
[netbsd-mini2440.git] / external / bsd / openldap / dist / include / ldap_pvt_thread.h
blobd0c4e1e6947558472acd71ebcb0aa7048367af53
1 /* ldap_pvt_thread.h - ldap threads header file */
2 /* $OpenLDAP: pkg/ldap/include/ldap_pvt_thread.h,v 1.51.2.10 2008/03/21 00:46:03 hyc Exp $ */
3 /* This work is part of OpenLDAP Software <http://www.openldap.org/>.
4 *
5 * Copyright 1998-2008 The OpenLDAP Foundation.
6 * All rights reserved.
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.
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>.
17 #ifndef _LDAP_PVT_THREAD_H
18 #define _LDAP_PVT_THREAD_H /* libldap_r/ldap_thr_debug.h #undefines this */
20 #include "ldap_cdefs.h"
21 #include "ldap_int_thread.h"
23 LDAP_BEGIN_DECL
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 typedef ldap_int_thread_rmutex_t ldap_pvt_thread_rmutex_t;
37 typedef ldap_int_thread_key_t ldap_pvt_thread_key_t;
38 #endif /* !LDAP_PVT_THREAD_H_DONE */
40 #define ldap_pvt_thread_equal ldap_int_thread_equal
42 LDAP_F( int )
43 ldap_pvt_thread_initialize LDAP_P(( void ));
45 LDAP_F( int )
46 ldap_pvt_thread_destroy LDAP_P(( void ));
48 LDAP_F( unsigned int )
49 ldap_pvt_thread_sleep LDAP_P(( unsigned int s ));
51 LDAP_F( int )
52 ldap_pvt_thread_get_concurrency LDAP_P(( void ));
54 LDAP_F( int )
55 ldap_pvt_thread_set_concurrency LDAP_P(( int ));
57 #define LDAP_PVT_THREAD_CREATE_JOINABLE 0
58 #define LDAP_PVT_THREAD_CREATE_DETACHED 1
60 #ifndef LDAP_PVT_THREAD_H_DONE
61 #define LDAP_PVT_THREAD_SET_STACK_SIZE
62 #ifndef LDAP_PVT_THREAD_STACK_SIZE
63 /* LARGE stack. Will be twice as large on 64 bit machine. */
64 #define LDAP_PVT_THREAD_STACK_SIZE ( 1 * 1024 * 1024 * sizeof(void *) )
65 /* May be explicitly defined to zero to disable it */
66 #elif LDAP_PVT_THREAD_STACK_SIZE == 0
67 #undef LDAP_PVT_THREAD_SET_STACK_SIZE
68 #endif
69 #endif /* !LDAP_PVT_THREAD_H_DONE */
71 LDAP_F( int )
72 ldap_pvt_thread_create LDAP_P((
73 ldap_pvt_thread_t * thread,
74 int detach,
75 void *(*start_routine)( void * ),
76 void *arg));
78 LDAP_F( void )
79 ldap_pvt_thread_exit LDAP_P(( void *retval ));
81 LDAP_F( int )
82 ldap_pvt_thread_join LDAP_P(( ldap_pvt_thread_t thread, void **status ));
84 LDAP_F( int )
85 ldap_pvt_thread_kill LDAP_P(( ldap_pvt_thread_t thread, int signo ));
87 LDAP_F( int )
88 ldap_pvt_thread_yield LDAP_P(( void ));
90 LDAP_F( int )
91 ldap_pvt_thread_cond_init LDAP_P(( ldap_pvt_thread_cond_t *cond ));
93 LDAP_F( int )
94 ldap_pvt_thread_cond_destroy LDAP_P(( ldap_pvt_thread_cond_t *cond ));
96 LDAP_F( int )
97 ldap_pvt_thread_cond_signal LDAP_P(( ldap_pvt_thread_cond_t *cond ));
99 LDAP_F( int )
100 ldap_pvt_thread_cond_broadcast LDAP_P(( ldap_pvt_thread_cond_t *cond ));
102 LDAP_F( int )
103 ldap_pvt_thread_cond_wait LDAP_P((
104 ldap_pvt_thread_cond_t *cond,
105 ldap_pvt_thread_mutex_t *mutex ));
107 LDAP_F( int )
108 ldap_pvt_thread_mutex_init LDAP_P(( ldap_pvt_thread_mutex_t *mutex ));
110 LDAP_F( int )
111 ldap_pvt_thread_mutex_destroy LDAP_P(( ldap_pvt_thread_mutex_t *mutex ));
113 LDAP_F( int )
114 ldap_pvt_thread_mutex_lock LDAP_P(( ldap_pvt_thread_mutex_t *mutex ));
116 LDAP_F( int )
117 ldap_pvt_thread_mutex_trylock LDAP_P(( ldap_pvt_thread_mutex_t *mutex ));
119 LDAP_F( int )
120 ldap_pvt_thread_mutex_unlock LDAP_P(( ldap_pvt_thread_mutex_t *mutex ));
122 LDAP_F( int )
123 ldap_pvt_thread_rmutex_init LDAP_P(( ldap_pvt_thread_rmutex_t *rmutex ));
125 LDAP_F( int )
126 ldap_pvt_thread_rmutex_destroy LDAP_P(( ldap_pvt_thread_rmutex_t *rmutex ));
128 LDAP_F( int )
129 ldap_pvt_thread_rmutex_lock LDAP_P(( ldap_pvt_thread_rmutex_t *rmutex,
130 ldap_pvt_thread_t owner));
132 LDAP_F( int )
133 ldap_pvt_thread_rmutex_trylock LDAP_P(( ldap_pvt_thread_rmutex_t *rmutex,
134 ldap_pvt_thread_t owner));
136 LDAP_F( int )
137 ldap_pvt_thread_rmutex_unlock LDAP_P(( ldap_pvt_thread_rmutex_t *rmutex,
138 ldap_pvt_thread_t owner));
140 LDAP_F( ldap_pvt_thread_t )
141 ldap_pvt_thread_self LDAP_P(( void ));
143 #ifdef LDAP_INT_THREAD_ASSERT_MUTEX_OWNER
144 #define LDAP_PVT_THREAD_ASSERT_MUTEX_OWNER LDAP_INT_THREAD_ASSERT_MUTEX_OWNER
145 #else
146 #define LDAP_PVT_THREAD_ASSERT_MUTEX_OWNER(mutex) ((void) 0)
147 #endif
149 LDAP_F( int )
150 ldap_pvt_thread_rdwr_init LDAP_P((ldap_pvt_thread_rdwr_t *rdwrp));
152 LDAP_F( int )
153 ldap_pvt_thread_rdwr_destroy LDAP_P((ldap_pvt_thread_rdwr_t *rdwrp));
155 LDAP_F( int )
156 ldap_pvt_thread_rdwr_rlock LDAP_P((ldap_pvt_thread_rdwr_t *rdwrp));
158 LDAP_F( int )
159 ldap_pvt_thread_rdwr_rtrylock LDAP_P((ldap_pvt_thread_rdwr_t *rdwrp));
161 LDAP_F( int )
162 ldap_pvt_thread_rdwr_runlock LDAP_P((ldap_pvt_thread_rdwr_t *rdwrp));
164 LDAP_F( int )
165 ldap_pvt_thread_rdwr_wlock LDAP_P((ldap_pvt_thread_rdwr_t *rdwrp));
167 LDAP_F( int )
168 ldap_pvt_thread_rdwr_wtrylock LDAP_P((ldap_pvt_thread_rdwr_t *rdwrp));
170 LDAP_F( int )
171 ldap_pvt_thread_rdwr_wunlock LDAP_P((ldap_pvt_thread_rdwr_t *rdwrp));
173 LDAP_F( int )
174 ldap_pvt_thread_key_create LDAP_P((ldap_pvt_thread_key_t *keyp));
176 LDAP_F( int )
177 ldap_pvt_thread_key_destroy LDAP_P((ldap_pvt_thread_key_t key));
179 LDAP_F( int )
180 ldap_pvt_thread_key_setdata LDAP_P((ldap_pvt_thread_key_t key, void *data));
182 LDAP_F( int )
183 ldap_pvt_thread_key_getdata LDAP_P((ldap_pvt_thread_key_t key, void **data));
185 #ifdef LDAP_DEBUG
186 LDAP_F( int )
187 ldap_pvt_thread_rdwr_readers LDAP_P((ldap_pvt_thread_rdwr_t *rdwrp));
189 LDAP_F( int )
190 ldap_pvt_thread_rdwr_writers LDAP_P((ldap_pvt_thread_rdwr_t *rdwrp));
192 LDAP_F( int )
193 ldap_pvt_thread_rdwr_active LDAP_P((ldap_pvt_thread_rdwr_t *rdwrp));
194 #endif /* LDAP_DEBUG */
196 #define LDAP_PVT_THREAD_EINVAL EINVAL
197 #define LDAP_PVT_THREAD_EBUSY EINVAL
199 #ifndef LDAP_PVT_THREAD_H_DONE
200 typedef ldap_int_thread_pool_t ldap_pvt_thread_pool_t;
202 typedef void * (ldap_pvt_thread_start_t) LDAP_P((void *ctx, void *arg));
203 typedef void (ldap_pvt_thread_pool_keyfree_t) LDAP_P((void *key, void *data));
204 #endif /* !LDAP_PVT_THREAD_H_DONE */
206 LDAP_F( int )
207 ldap_pvt_thread_pool_init LDAP_P((
208 ldap_pvt_thread_pool_t *pool_out,
209 int max_threads,
210 int max_pending ));
212 LDAP_F( int )
213 ldap_pvt_thread_pool_submit LDAP_P((
214 ldap_pvt_thread_pool_t *pool,
215 ldap_pvt_thread_start_t *start,
216 void *arg ));
218 LDAP_F( int )
219 ldap_pvt_thread_pool_maxthreads LDAP_P((
220 ldap_pvt_thread_pool_t *pool,
221 int max_threads ));
223 #ifndef LDAP_PVT_THREAD_H_DONE
224 typedef enum {
225 LDAP_PVT_THREAD_POOL_PARAM_UNKNOWN = -1,
226 LDAP_PVT_THREAD_POOL_PARAM_MAX,
227 LDAP_PVT_THREAD_POOL_PARAM_MAX_PENDING,
228 LDAP_PVT_THREAD_POOL_PARAM_OPEN,
229 LDAP_PVT_THREAD_POOL_PARAM_STARTING,
230 LDAP_PVT_THREAD_POOL_PARAM_ACTIVE,
231 LDAP_PVT_THREAD_POOL_PARAM_PAUSING,
232 LDAP_PVT_THREAD_POOL_PARAM_PENDING,
233 LDAP_PVT_THREAD_POOL_PARAM_BACKLOAD,
234 LDAP_PVT_THREAD_POOL_PARAM_ACTIVE_MAX,
235 LDAP_PVT_THREAD_POOL_PARAM_PENDING_MAX,
236 LDAP_PVT_THREAD_POOL_PARAM_BACKLOAD_MAX,
237 LDAP_PVT_THREAD_POOL_PARAM_STATE
238 } ldap_pvt_thread_pool_param_t;
239 #endif /* !LDAP_PVT_THREAD_H_DONE */
241 LDAP_F( int )
242 ldap_pvt_thread_pool_query LDAP_P((
243 ldap_pvt_thread_pool_t *pool,
244 ldap_pvt_thread_pool_param_t param, void *value ));
246 LDAP_F( int )
247 ldap_pvt_thread_pool_pausing LDAP_P((
248 ldap_pvt_thread_pool_t *pool ));
250 LDAP_F( int )
251 ldap_pvt_thread_pool_backload LDAP_P((
252 ldap_pvt_thread_pool_t *pool ));
254 LDAP_F( int )
255 ldap_pvt_thread_pool_pausecheck LDAP_P((
256 ldap_pvt_thread_pool_t *pool ));
258 LDAP_F( int )
259 ldap_pvt_thread_pool_pause LDAP_P((
260 ldap_pvt_thread_pool_t *pool ));
262 LDAP_F( int )
263 ldap_pvt_thread_pool_resume LDAP_P((
264 ldap_pvt_thread_pool_t *pool ));
266 LDAP_F( int )
267 ldap_pvt_thread_pool_destroy LDAP_P((
268 ldap_pvt_thread_pool_t *pool,
269 int run_pending ));
271 LDAP_F( int )
272 ldap_pvt_thread_pool_getkey LDAP_P((
273 void *ctx,
274 void *key,
275 void **data,
276 ldap_pvt_thread_pool_keyfree_t **kfree ));
278 LDAP_F( int )
279 ldap_pvt_thread_pool_setkey LDAP_P((
280 void *ctx,
281 void *key,
282 void *data,
283 ldap_pvt_thread_pool_keyfree_t *kfree,
284 void **olddatap,
285 ldap_pvt_thread_pool_keyfree_t **oldkfreep ));
287 LDAP_F( void )
288 ldap_pvt_thread_pool_purgekey LDAP_P(( void *key ));
290 LDAP_F( void *)
291 ldap_pvt_thread_pool_context LDAP_P(( void ));
293 LDAP_F( void )
294 ldap_pvt_thread_pool_context_reset LDAP_P(( void *key ));
296 LDAP_F( ldap_pvt_thread_t )
297 ldap_pvt_thread_pool_tid LDAP_P(( void *ctx ));
299 LDAP_END_DECL
301 #define LDAP_PVT_THREAD_H_DONE
302 #endif /* _LDAP_PVT_THREAD_H */