2 /* This work is part of OpenLDAP Software <http://www.openldap.org/>.
4 * Copyright 1998-2006 The OpenLDAP Foundation.
7 * Redistribution and use in source and binary forms, with or without
8 * modification, are permitted only as authorized by the OpenLDAP
11 * A copy of this license is available in file LICENSE in the
12 * top-level directory of the distribution or, alternatively, at
13 * <http://www.OpenLDAP.org/license.html>.
20 #include <ac/stdarg.h>
21 #include <ac/stdlib.h>
22 #include <ac/string.h>
23 #include <ac/unistd.h>
25 #include "ldap_pvt_thread.h" /* Get the thread interface */
26 #include "ldap_thr_debug.h" /* May redirect thread initialize/destroy calls */
30 * Common LDAP thread routines
31 * see thr_*.c for implementation specific routines
32 * see rdwr.c for generic reader/writer lock implementation
33 * see tpool.c for generic thread pool implementation
37 int ldap_pvt_thread_initialize( void )
42 /* we only get one shot at this */
43 if( init++ ) return -1;
45 rc = ldap_int_thread_initialize();
48 #ifndef LDAP_THREAD_HAVE_TPOOL
49 rc = ldap_int_thread_pool_startup();
56 int ldap_pvt_thread_destroy( void )
58 #ifndef LDAP_THREAD_HAVE_TPOOL
59 (void) ldap_int_thread_pool_shutdown();
61 return ldap_int_thread_destroy();
66 * Default implementations of some LDAP thread routines
69 #define LDAP_THREAD_IMPLEMENTATION
70 #include "ldap_thr_debug.h" /* May rename the symbols defined below */
73 #ifndef LDAP_THREAD_HAVE_GETCONCURRENCY
75 ldap_pvt_thread_get_concurrency ( void )
81 #ifndef LDAP_THREAD_HAVE_SETCONCURRENCY
83 ldap_pvt_thread_set_concurrency ( int concurrency )
89 #ifndef LDAP_THREAD_HAVE_SLEEP
91 * Here we assume we have fully preemptive threads and that sleep()
92 * does the right thing.
95 ldap_pvt_thread_sleep(