2 /* This work is part of OpenLDAP Software <http://www.openldap.org/>.
4 * Copyright 1998-2005 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"
29 * Common LDAP thread routines
30 * see thr_*.c for implementation specific routines
31 * see rdwr.c for generic reader/writer lock implementation
32 * see tpool.c for generic thread pool implementation
36 int ldap_pvt_thread_initialize( void )
41 /* we only get one shot at this */
42 if( init++ ) return -1;
44 rc = ldap_int_thread_initialize();
47 #ifndef LDAP_THREAD_HAVE_TPOOL
48 rc = ldap_int_thread_pool_startup();
55 int ldap_pvt_thread_destroy( void )
57 #ifndef LDAP_THREAD_HAVE_TPOOL
58 (void) ldap_int_thread_pool_shutdown();
60 return ldap_int_thread_destroy();
63 #ifndef LDAP_THREAD_HAVE_GETCONCURRENCY
65 ldap_pvt_thread_get_concurrency ( void )
71 #ifndef LDAP_THREAD_HAVE_SETCONCURRENCY
73 ldap_pvt_thread_set_concurrency ( int concurrency )
79 #ifndef LDAP_THREAD_HAVE_SLEEP
81 * Here we assume we have fully preemptive threads and that sleep()
82 * does the right thing.
85 ldap_pvt_thread_sleep(