]> git.sur5r.net Git - openldap/blob - include/ldap_pvt_thread.h
Low stack to 16 MB... this really needs to be tunable
[openldap] / include / ldap_pvt_thread.h
1 /* $OpenLDAP$ */
2 /*
3  * Copyright 1998-2001 The OpenLDAP Foundation, Redwood City, California, USA
4  * All rights reserved.
5  *
6  * Redistribution and use in source and binary forms, with or without
7  * modification, are permitted only as authorized by the OpenLDAP
8  * Public License.  A copy of this license is available at
9  * http://www.OpenLDAP.org/license.html or in file LICENSE in the
10  * top-level directory of the distribution.
11  */
12 /* ldap_pvt_thread.h - ldap threads header file NG */
13
14 #ifndef _LDAP_PVT_THREAD_H
15 #define _LDAP_PVT_THREAD_H
16
17 #include "ldap_cdefs.h"
18 #include "ldap_int_thread.h"
19
20 LDAP_BEGIN_DECL
21
22 typedef ldap_int_thread_t ldap_pvt_thread_t;
23 typedef ldap_int_thread_mutex_t ldap_pvt_thread_mutex_t;
24 typedef ldap_int_thread_cond_t ldap_pvt_thread_cond_t;
25
26 LDAP_F( int )
27 ldap_pvt_thread_initialize LDAP_P(( void ));
28
29 LDAP_F( int )
30 ldap_pvt_thread_destroy LDAP_P(( void ));
31
32 LDAP_F( unsigned int )
33 ldap_pvt_thread_sleep LDAP_P(( unsigned int s ));
34
35 LDAP_F( int )
36 ldap_pvt_thread_get_concurrency LDAP_P(( void ));
37
38 LDAP_F( int )
39 ldap_pvt_thread_set_concurrency LDAP_P(( int ));
40
41 #define LDAP_PVT_THREAD_CREATE_JOINABLE 0
42 #define LDAP_PVT_THREAD_CREATE_DETACHED 1
43
44 #ifndef LDAP_PVT_THREAD_STACK_SIZE
45         /* LARGE stack */
46 #define LDAP_PVT_THREAD_STACK_SIZE      (16*1024*1024)
47 #endif
48
49 LDAP_F( int ) 
50 ldap_pvt_thread_create LDAP_P((
51         ldap_pvt_thread_t * thread, 
52         int     detach,
53         void *(*start_routine)( void * ), 
54         void *arg));
55
56 LDAP_F( void ) 
57 ldap_pvt_thread_exit LDAP_P(( void *retval ));
58
59 LDAP_F( int )
60 ldap_pvt_thread_join LDAP_P(( ldap_pvt_thread_t thread, void **status ));
61
62 LDAP_F( int )
63 ldap_pvt_thread_kill LDAP_P(( ldap_pvt_thread_t thread, int signo ));
64
65 LDAP_F( int )
66 ldap_pvt_thread_yield LDAP_P(( void ));
67
68 LDAP_F( int )
69 ldap_pvt_thread_cond_init LDAP_P(( ldap_pvt_thread_cond_t *cond ));
70
71 LDAP_F( int )
72 ldap_pvt_thread_cond_destroy LDAP_P(( ldap_pvt_thread_cond_t *cond ));
73
74 LDAP_F( int )
75 ldap_pvt_thread_cond_signal LDAP_P(( ldap_pvt_thread_cond_t *cond ));
76
77 LDAP_F( int )
78 ldap_pvt_thread_cond_broadcast LDAP_P(( ldap_pvt_thread_cond_t *cond ));
79
80 LDAP_F( int )
81 ldap_pvt_thread_cond_wait LDAP_P((
82         ldap_pvt_thread_cond_t *cond, 
83         ldap_pvt_thread_mutex_t *mutex ));
84
85 LDAP_F( int )
86 ldap_pvt_thread_mutex_init LDAP_P(( ldap_pvt_thread_mutex_t *mutex ));
87
88 LDAP_F( int )
89 ldap_pvt_thread_mutex_destroy LDAP_P(( ldap_pvt_thread_mutex_t *mutex ));
90
91 LDAP_F( int )
92 ldap_pvt_thread_mutex_lock LDAP_P(( ldap_pvt_thread_mutex_t *mutex ));
93
94 LDAP_F( int )
95 ldap_pvt_thread_mutex_trylock LDAP_P(( ldap_pvt_thread_mutex_t *mutex ));
96
97 LDAP_F( int )
98 ldap_pvt_thread_mutex_unlock LDAP_P(( ldap_pvt_thread_mutex_t *mutex ));
99
100 #ifndef LDAP_THREAD_HAVE_RDWR
101 typedef struct ldap_int_thread_rdwr_s * ldap_pvt_thread_rdwr_t;
102 #endif
103
104 LDAP_F( int )
105 ldap_pvt_thread_rdwr_init LDAP_P((ldap_pvt_thread_rdwr_t *rdwrp));
106
107 LDAP_F( int )
108 ldap_pvt_thread_rdwr_destroy LDAP_P((ldap_pvt_thread_rdwr_t *rdwrp));
109
110 LDAP_F( int )
111 ldap_pvt_thread_rdwr_rlock LDAP_P((ldap_pvt_thread_rdwr_t *rdwrp));
112
113 LDAP_F( int )
114 ldap_pvt_thread_rdwr_rtrylock LDAP_P((ldap_pvt_thread_rdwr_t *rdwrp));
115
116 LDAP_F( int )
117 ldap_pvt_thread_rdwr_runlock LDAP_P((ldap_pvt_thread_rdwr_t *rdwrp));
118
119 LDAP_F( int )
120 ldap_pvt_thread_rdwr_wlock LDAP_P((ldap_pvt_thread_rdwr_t *rdwrp));
121
122 LDAP_F( int )
123 ldap_pvt_thread_rdwr_wtrylock LDAP_P((ldap_pvt_thread_rdwr_t *rdwrp));
124
125 LDAP_F( int )
126 ldap_pvt_thread_rdwr_wunlock LDAP_P((ldap_pvt_thread_rdwr_t *rdwrp));
127
128 #ifdef LDAP_DEBUG
129 LDAP_F( int )
130 ldap_pvt_thread_rdwr_readers LDAP_P((ldap_pvt_thread_rdwr_t *rdwrp));
131
132 LDAP_F( int )
133 ldap_pvt_thread_rdwr_writers LDAP_P((ldap_pvt_thread_rdwr_t *rdwrp));
134
135 LDAP_F( int )
136 ldap_pvt_thread_rdwr_active LDAP_P((ldap_pvt_thread_rdwr_t *rdwrp));
137 #endif /* LDAP_DEBUG */
138
139 #define LDAP_PVT_THREAD_EINVAL EINVAL
140 #define LDAP_PVT_THREAD_EBUSY EINVAL
141
142 typedef ldap_int_thread_pool_t ldap_pvt_thread_pool_t;
143
144 LDAP_F( int )
145 ldap_pvt_thread_pool_init LDAP_P((
146         ldap_pvt_thread_pool_t *pool_out,
147         int max_threads,
148         int max_pending ));
149
150 LDAP_F( int )
151 ldap_pvt_thread_pool_submit LDAP_P((
152         ldap_pvt_thread_pool_t *pool,
153         void *(*start_routine)( void * ),
154         void *arg ));
155
156 LDAP_F( int )
157 ldap_pvt_thread_pool_maxthreads LDAP_P((
158         ldap_pvt_thread_pool_t *pool,
159         int max_threads ));
160
161 LDAP_F( int )
162 ldap_pvt_thread_pool_backload LDAP_P((
163         ldap_pvt_thread_pool_t *pool ));
164
165 LDAP_F( int )
166 ldap_pvt_thread_pool_destroy LDAP_P((
167         ldap_pvt_thread_pool_t *pool,
168         int run_pending ));
169
170
171 LDAP_END_DECL
172
173 #endif /* _LDAP_THREAD_H */