]> git.sur5r.net Git - openldap/blob - libraries/libldap_r/threads.c
needs string.h
[openldap] / libraries / libldap_r / threads.c
1 /* $OpenLDAP$ */
2 /*
3  * Copyright 1998-2000 The OpenLDAP Foundation, Redwood City, California, USA
4  * All rights reserved.
5  *
6  * Redistribution and use in source and binary forms are permitted only
7  * as authorized by the OpenLDAP Public License.  A copy of this
8  * license is available at http://www.OpenLDAP.org/license.html or
9  * in file LICENSE in the top-level directory of the distribution.
10  */
11
12 #include "portable.h"
13
14 #include <stdio.h>
15 #include <stdarg.h>
16
17 #include <ac/stdlib.h>
18 #include <ac/string.h>
19
20 #include "ldap_pvt_thread.h"
21
22
23 /*
24  * Common LDAP thread routines
25  *      see thr_*.c for implementation specific routines
26  *      see rdwr.c for generic reader/writer lock implementation
27  *      see tpool.c for generic thread pool implementation
28  */
29
30
31 int ldap_pvt_thread_initialize( void )
32 {
33         int rc;
34         static int init = 0;
35
36         /* we only get one shot at this */
37         if( init++ ) return -1;
38
39         rc = ldap_int_thread_initialize();
40         if( rc ) return rc;
41
42 #ifndef LDAP_THREAD_HAVE_TPOOL
43         rc = ldap_int_thread_pool_startup();
44         if( rc ) return rc;
45 #endif
46
47         return 0;
48 }
49
50 int ldap_pvt_thread_destroy( void )
51 {
52 #ifndef LDAP_THREAD_HAVE_TPOOL
53         (void) ldap_int_thread_pool_shutdown();
54 #endif
55         return ldap_int_thread_destroy();
56 }
57
58 #ifndef LDAP_THREAD_HAVE_GETCONCURRENCY
59 int
60 ldap_pvt_thread_get_concurrency ( void )
61 {
62         return 1;
63 }
64 #endif
65
66 #ifndef LDAP_THREAD_HAVE_SETCONCURRENCY
67 int
68 ldap_pvt_thread_set_concurrency ( int concurrency )
69 {
70         return 1;
71 }
72 #endif
73
74 #ifndef LDAP_THREAD_HAVE_SLEEP
75 /*
76  * Here we assume we have fully preemptive threads and that sleep()
77  * does the right thing.
78  */
79 unsigned int
80 ldap_pvt_thread_sleep(
81         unsigned int interval
82 )
83 {
84         sleep( interval );
85         return 0;
86 }
87 #endif