]> git.sur5r.net Git - openldap/blob - libraries/libldap_r/threads.c
Add filter.c
[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
16 #include <ac/stdarg.h>
17 #include <ac/stdlib.h>
18 #include <ac/string.h>
19 #include <ac/unistd.h>
20
21 #include "ldap_pvt_thread.h"
22
23
24 /*
25  * Common LDAP thread routines
26  *      see thr_*.c for implementation specific routines
27  *      see rdwr.c for generic reader/writer lock implementation
28  *      see tpool.c for generic thread pool implementation
29  */
30
31
32 int ldap_pvt_thread_initialize( void )
33 {
34         int rc;
35         static int init = 0;
36
37         /* we only get one shot at this */
38         if( init++ ) return -1;
39
40         rc = ldap_int_thread_initialize();
41         if( rc ) return rc;
42
43 #ifndef LDAP_THREAD_HAVE_TPOOL
44         rc = ldap_int_thread_pool_startup();
45         if( rc ) return rc;
46 #endif
47
48         return 0;
49 }
50
51 int ldap_pvt_thread_destroy( void )
52 {
53 #ifndef LDAP_THREAD_HAVE_TPOOL
54         (void) ldap_int_thread_pool_shutdown();
55 #endif
56         return ldap_int_thread_destroy();
57 }
58
59 #ifndef LDAP_THREAD_HAVE_GETCONCURRENCY
60 int
61 ldap_pvt_thread_get_concurrency ( void )
62 {
63         return 1;
64 }
65 #endif
66
67 #ifndef LDAP_THREAD_HAVE_SETCONCURRENCY
68 int
69 ldap_pvt_thread_set_concurrency ( int concurrency )
70 {
71         return 1;
72 }
73 #endif
74
75 #ifndef LDAP_THREAD_HAVE_SLEEP
76 /*
77  * Here we assume we have fully preemptive threads and that sleep()
78  * does the right thing.
79  */
80 unsigned int
81 ldap_pvt_thread_sleep(
82         unsigned int interval
83 )
84 {
85         sleep( interval );
86         return 0;
87 }
88 #endif