Back to index

openldap  2.4.31
ldap_pvt_thread.h
Go to the documentation of this file.
00001 /* ldap_pvt_thread.h - ldap threads header file */
00002 /* $OpenLDAP$ */
00003 /* This work is part of OpenLDAP Software <http://www.openldap.org/>.
00004  * 
00005  * Copyright 1998-2012 The OpenLDAP Foundation.
00006  * All rights reserved.
00007  *
00008  * Redistribution and use in source and binary forms, with or without
00009  * modification, are permitted only as authorized by the OpenLDAP
00010  * Public License.
00011  *
00012  * A copy of this license is available in file LICENSE in the
00013  * top-level directory of the distribution or, alternatively, at
00014  * <http://www.OpenLDAP.org/license.html>.
00015  */
00016 
00017 #ifndef _LDAP_PVT_THREAD_H
00018 #define _LDAP_PVT_THREAD_H /* libldap_r/ldap_thr_debug.h #undefines this */
00019 
00020 #include "ldap_cdefs.h"
00021 #include "ldap_int_thread.h"
00022 
00023 LDAP_BEGIN_DECL
00024 
00025 #ifndef LDAP_PVT_THREAD_H_DONE
00026 typedef ldap_int_thread_t                 ldap_pvt_thread_t;
00027 #ifdef LDAP_THREAD_DEBUG_WRAP
00028 typedef ldap_debug_thread_mutex_t  ldap_pvt_thread_mutex_t;
00029 typedef ldap_debug_thread_cond_t   ldap_pvt_thread_cond_t;
00030 typedef ldap_debug_thread_rdwr_t   ldap_pvt_thread_rdwr_t;
00031 #define LDAP_PVT_MUTEX_FIRSTCREATE LDAP_DEBUG_MUTEX_FIRSTCREATE
00032 #define LDAP_PVT_MUTEX_NULL               LDAP_DEBUG_MUTEX_NULL
00033 #else
00034 typedef ldap_int_thread_mutex_t           ldap_pvt_thread_mutex_t;
00035 typedef ldap_int_thread_cond_t            ldap_pvt_thread_cond_t;
00036 typedef ldap_int_thread_rdwr_t            ldap_pvt_thread_rdwr_t;
00037 #define LDAP_PVT_MUTEX_FIRSTCREATE LDAP_INT_MUTEX_FIRSTCREATE
00038 #define LDAP_PVT_MUTEX_NULL               LDAP_INT_MUTEX_NULL
00039 #endif
00040 typedef ldap_int_thread_rmutex_t   ldap_pvt_thread_rmutex_t;
00041 typedef ldap_int_thread_key_t      ldap_pvt_thread_key_t;
00042 #endif /* !LDAP_PVT_THREAD_H_DONE */
00043 
00044 #define ldap_pvt_thread_equal             ldap_int_thread_equal
00045 
00046 LDAP_F( int )
00047 ldap_pvt_thread_initialize LDAP_P(( void ));
00048 
00049 LDAP_F( int )
00050 ldap_pvt_thread_destroy LDAP_P(( void ));
00051 
00052 LDAP_F( unsigned int )
00053 ldap_pvt_thread_sleep LDAP_P(( unsigned int s ));
00054 
00055 LDAP_F( int )
00056 ldap_pvt_thread_get_concurrency LDAP_P(( void ));
00057 
00058 LDAP_F( int )
00059 ldap_pvt_thread_set_concurrency LDAP_P(( int ));
00060 
00061 #define LDAP_PVT_THREAD_CREATE_JOINABLE 0
00062 #define LDAP_PVT_THREAD_CREATE_DETACHED 1
00063 
00064 #ifndef LDAP_PVT_THREAD_H_DONE
00065 #define       LDAP_PVT_THREAD_SET_STACK_SIZE
00066 /* The size may be explicitly #defined to zero to disable it. */
00067 #if defined( LDAP_PVT_THREAD_STACK_SIZE ) && LDAP_PVT_THREAD_STACK_SIZE == 0
00068 #      undef LDAP_PVT_THREAD_SET_STACK_SIZE
00069 #elif !defined( LDAP_PVT_THREAD_STACK_SIZE )
00070        /* LARGE stack. Will be twice as large on 64 bit machine. */
00071 #      define LDAP_PVT_THREAD_STACK_SIZE ( 1 * 1024 * 1024 * sizeof(void *) )
00072 #endif
00073 #endif /* !LDAP_PVT_THREAD_H_DONE */
00074 
00075 LDAP_F( int )
00076 ldap_pvt_thread_create LDAP_P((
00077        ldap_pvt_thread_t * thread,
00078        int    detach,
00079        void *(*start_routine)( void * ),
00080        void *arg));
00081 
00082 LDAP_F( void )
00083 ldap_pvt_thread_exit LDAP_P(( void *retval ));
00084 
00085 LDAP_F( int )
00086 ldap_pvt_thread_join LDAP_P(( ldap_pvt_thread_t thread, void **status ));
00087 
00088 LDAP_F( int )
00089 ldap_pvt_thread_kill LDAP_P(( ldap_pvt_thread_t thread, int signo ));
00090 
00091 LDAP_F( int )
00092 ldap_pvt_thread_yield LDAP_P(( void ));
00093 
00094 LDAP_F( int )
00095 ldap_pvt_thread_cond_init LDAP_P(( ldap_pvt_thread_cond_t *cond ));
00096 
00097 LDAP_F( int )
00098 ldap_pvt_thread_cond_destroy LDAP_P(( ldap_pvt_thread_cond_t *cond ));
00099 
00100 LDAP_F( int )
00101 ldap_pvt_thread_cond_signal LDAP_P(( ldap_pvt_thread_cond_t *cond ));
00102 
00103 LDAP_F( int )
00104 ldap_pvt_thread_cond_broadcast LDAP_P(( ldap_pvt_thread_cond_t *cond ));
00105 
00106 LDAP_F( int )
00107 ldap_pvt_thread_cond_wait LDAP_P((
00108        ldap_pvt_thread_cond_t *cond,
00109        ldap_pvt_thread_mutex_t *mutex ));
00110 
00111 LDAP_F( int )
00112 ldap_pvt_thread_mutex_init LDAP_P(( ldap_pvt_thread_mutex_t *mutex ));
00113 
00114 LDAP_F( int )
00115 ldap_pvt_thread_mutex_destroy LDAP_P(( ldap_pvt_thread_mutex_t *mutex ));
00116 
00117 LDAP_F( int )
00118 ldap_pvt_thread_mutex_lock LDAP_P(( ldap_pvt_thread_mutex_t *mutex ));
00119 
00120 LDAP_F( int )
00121 ldap_pvt_thread_mutex_trylock LDAP_P(( ldap_pvt_thread_mutex_t *mutex ));
00122 
00123 LDAP_F( int )
00124 ldap_pvt_thread_mutex_unlock LDAP_P(( ldap_pvt_thread_mutex_t *mutex ));
00125 
00126 LDAP_F( int )
00127 ldap_pvt_thread_rmutex_init LDAP_P(( ldap_pvt_thread_rmutex_t *rmutex ));
00128 
00129 LDAP_F( int )
00130 ldap_pvt_thread_rmutex_destroy LDAP_P(( ldap_pvt_thread_rmutex_t *rmutex ));
00131 
00132 LDAP_F( int )
00133 ldap_pvt_thread_rmutex_lock LDAP_P(( ldap_pvt_thread_rmutex_t *rmutex,
00134        ldap_pvt_thread_t owner));
00135 
00136 LDAP_F( int )
00137 ldap_pvt_thread_rmutex_trylock LDAP_P(( ldap_pvt_thread_rmutex_t *rmutex,
00138        ldap_pvt_thread_t owner));
00139 
00140 LDAP_F( int )
00141 ldap_pvt_thread_rmutex_unlock LDAP_P(( ldap_pvt_thread_rmutex_t *rmutex,
00142        ldap_pvt_thread_t owner));
00143 
00144 LDAP_F( ldap_pvt_thread_t )
00145 ldap_pvt_thread_self LDAP_P(( void ));
00146 
00147 #ifdef LDAP_INT_THREAD_ASSERT_MUTEX_OWNER
00148 #define       LDAP_PVT_THREAD_ASSERT_MUTEX_OWNER LDAP_INT_THREAD_ASSERT_MUTEX_OWNER
00149 #else
00150 #define       LDAP_PVT_THREAD_ASSERT_MUTEX_OWNER(mutex) ((void) 0)
00151 #endif
00152 
00153 LDAP_F( int )
00154 ldap_pvt_thread_rdwr_init LDAP_P((ldap_pvt_thread_rdwr_t *rdwrp));
00155 
00156 LDAP_F( int )
00157 ldap_pvt_thread_rdwr_destroy LDAP_P((ldap_pvt_thread_rdwr_t *rdwrp));
00158 
00159 LDAP_F( int )
00160 ldap_pvt_thread_rdwr_rlock LDAP_P((ldap_pvt_thread_rdwr_t *rdwrp));
00161 
00162 LDAP_F( int )
00163 ldap_pvt_thread_rdwr_rtrylock LDAP_P((ldap_pvt_thread_rdwr_t *rdwrp));
00164 
00165 LDAP_F( int )
00166 ldap_pvt_thread_rdwr_runlock LDAP_P((ldap_pvt_thread_rdwr_t *rdwrp));
00167 
00168 LDAP_F( int )
00169 ldap_pvt_thread_rdwr_wlock LDAP_P((ldap_pvt_thread_rdwr_t *rdwrp));
00170 
00171 LDAP_F( int )
00172 ldap_pvt_thread_rdwr_wtrylock LDAP_P((ldap_pvt_thread_rdwr_t *rdwrp));
00173 
00174 LDAP_F( int )
00175 ldap_pvt_thread_rdwr_wunlock LDAP_P((ldap_pvt_thread_rdwr_t *rdwrp));
00176 
00177 LDAP_F( int )
00178 ldap_pvt_thread_key_create LDAP_P((ldap_pvt_thread_key_t *keyp));
00179 
00180 LDAP_F( int )
00181 ldap_pvt_thread_key_destroy LDAP_P((ldap_pvt_thread_key_t key));
00182 
00183 LDAP_F( int )
00184 ldap_pvt_thread_key_setdata LDAP_P((ldap_pvt_thread_key_t key, void *data));
00185 
00186 LDAP_F( int )
00187 ldap_pvt_thread_key_getdata LDAP_P((ldap_pvt_thread_key_t key, void **data));
00188 
00189 #ifdef LDAP_DEBUG
00190 LDAP_F( int )
00191 ldap_pvt_thread_rdwr_readers LDAP_P((ldap_pvt_thread_rdwr_t *rdwrp));
00192 
00193 LDAP_F( int )
00194 ldap_pvt_thread_rdwr_writers LDAP_P((ldap_pvt_thread_rdwr_t *rdwrp));
00195 
00196 LDAP_F( int )
00197 ldap_pvt_thread_rdwr_active LDAP_P((ldap_pvt_thread_rdwr_t *rdwrp));
00198 #endif /* LDAP_DEBUG */
00199 
00200 #define LDAP_PVT_THREAD_EINVAL EINVAL
00201 #define LDAP_PVT_THREAD_EBUSY EINVAL
00202 
00203 #ifndef LDAP_PVT_THREAD_H_DONE
00204 typedef ldap_int_thread_pool_t ldap_pvt_thread_pool_t;
00205 
00206 typedef void * (ldap_pvt_thread_start_t) LDAP_P((void *ctx, void *arg));
00207 typedef void (ldap_pvt_thread_pool_keyfree_t) LDAP_P((void *key, void *data));
00208 #endif /* !LDAP_PVT_THREAD_H_DONE */
00209 
00210 LDAP_F( int )
00211 ldap_pvt_thread_pool_init LDAP_P((
00212        ldap_pvt_thread_pool_t *pool_out,
00213        int max_threads,
00214        int max_pending ));
00215 
00216 LDAP_F( int )
00217 ldap_pvt_thread_pool_submit LDAP_P((
00218        ldap_pvt_thread_pool_t *pool,
00219        ldap_pvt_thread_start_t *start,
00220        void *arg ));
00221 
00222 LDAP_F( int )
00223 ldap_pvt_thread_pool_retract LDAP_P((
00224        ldap_pvt_thread_pool_t *pool,
00225        ldap_pvt_thread_start_t *start,
00226        void *arg ));
00227 
00228 LDAP_F( int )
00229 ldap_pvt_thread_pool_maxthreads LDAP_P((
00230        ldap_pvt_thread_pool_t *pool,
00231        int max_threads ));
00232 
00233 #ifndef LDAP_PVT_THREAD_H_DONE
00234 typedef enum {
00235        LDAP_PVT_THREAD_POOL_PARAM_UNKNOWN = -1,
00236        LDAP_PVT_THREAD_POOL_PARAM_MAX,
00237        LDAP_PVT_THREAD_POOL_PARAM_MAX_PENDING,
00238        LDAP_PVT_THREAD_POOL_PARAM_OPEN,
00239        LDAP_PVT_THREAD_POOL_PARAM_STARTING,
00240        LDAP_PVT_THREAD_POOL_PARAM_ACTIVE,
00241        LDAP_PVT_THREAD_POOL_PARAM_PAUSING,
00242        LDAP_PVT_THREAD_POOL_PARAM_PENDING,
00243        LDAP_PVT_THREAD_POOL_PARAM_BACKLOAD,
00244        LDAP_PVT_THREAD_POOL_PARAM_ACTIVE_MAX,
00245        LDAP_PVT_THREAD_POOL_PARAM_PENDING_MAX,
00246        LDAP_PVT_THREAD_POOL_PARAM_BACKLOAD_MAX,
00247        LDAP_PVT_THREAD_POOL_PARAM_STATE
00248 } ldap_pvt_thread_pool_param_t;
00249 #endif /* !LDAP_PVT_THREAD_H_DONE */
00250 
00251 LDAP_F( int )
00252 ldap_pvt_thread_pool_query LDAP_P((
00253        ldap_pvt_thread_pool_t *pool,
00254        ldap_pvt_thread_pool_param_t param, void *value ));
00255 
00256 LDAP_F( int )
00257 ldap_pvt_thread_pool_pausing LDAP_P((
00258        ldap_pvt_thread_pool_t *pool ));
00259 
00260 LDAP_F( int )
00261 ldap_pvt_thread_pool_backload LDAP_P((
00262        ldap_pvt_thread_pool_t *pool ));
00263 
00264 LDAP_F( void )
00265 ldap_pvt_thread_pool_idle LDAP_P((
00266        ldap_pvt_thread_pool_t *pool ));
00267 
00268 LDAP_F( void )
00269 ldap_pvt_thread_pool_unidle LDAP_P((
00270        ldap_pvt_thread_pool_t *pool ));
00271 
00272 LDAP_F( int )
00273 ldap_pvt_thread_pool_pausecheck LDAP_P((
00274        ldap_pvt_thread_pool_t *pool ));
00275 
00276 LDAP_F( int )
00277 ldap_pvt_thread_pool_pause LDAP_P((
00278        ldap_pvt_thread_pool_t *pool ));
00279 
00280 LDAP_F( int )
00281 ldap_pvt_thread_pool_resume LDAP_P((
00282        ldap_pvt_thread_pool_t *pool ));
00283 
00284 LDAP_F( int )
00285 ldap_pvt_thread_pool_destroy LDAP_P((
00286        ldap_pvt_thread_pool_t *pool,
00287        int run_pending ));
00288 
00289 LDAP_F( int )
00290 ldap_pvt_thread_pool_getkey LDAP_P((
00291        void *ctx,
00292        void *key,
00293        void **data,
00294        ldap_pvt_thread_pool_keyfree_t **kfree ));
00295 
00296 LDAP_F( int )
00297 ldap_pvt_thread_pool_setkey LDAP_P((
00298        void *ctx,
00299        void *key,
00300        void *data,
00301        ldap_pvt_thread_pool_keyfree_t *kfree,
00302        void **olddatap,
00303        ldap_pvt_thread_pool_keyfree_t **oldkfreep ));
00304 
00305 LDAP_F( void )
00306 ldap_pvt_thread_pool_purgekey LDAP_P(( void *key ));
00307 
00308 LDAP_F( void *)
00309 ldap_pvt_thread_pool_context LDAP_P(( void ));
00310 
00311 LDAP_F( void )
00312 ldap_pvt_thread_pool_context_reset LDAP_P(( void *key ));
00313 
00314 LDAP_F( ldap_pvt_thread_t )
00315 ldap_pvt_thread_pool_tid LDAP_P(( void *ctx ));
00316 
00317 LDAP_END_DECL
00318 
00319 #define LDAP_PVT_THREAD_H_DONE
00320 #endif /* _LDAP_PVT_THREAD_H */