]> git.sur5r.net Git - openldap/blob - include/lthread_rdwr.h
Import op -> slap_op , conn -> slap_conn change from rel eng 1.1.
[openldap] / include / lthread_rdwr.h
1 /*
2  * Copyright 1998,1999 The OpenLDAP Foundation, Redwood City, California, USA
3  * All rights reserved.
4  *
5  * Redistribution and use in source and binary forms are permitted only
6  * as authorized by the OpenLDAP Public License.  A copy of this
7  * license is available at http://www.OpenLDAP.org/license.html or
8  * in file LICENSE in the top-level directory of the distribution.
9  */
10
11 #ifndef _LTHREAD_RDWR_H
12 #define _LTHREAD_RDWR_H 1
13
14 /********************************************************
15  * An example source module to accompany...
16  *
17  * "Using POSIX Threads: Programming with Pthreads"
18  *     by Brad nichols, Dick Buttlar, Jackie Farrell
19  *     O'Reilly & Associates, Inc.
20  *
21  ********************************************************
22  * 
23  * Include file for reader/writer locks
24  * 
25  */
26
27 #include <ldap_cdefs.h>
28
29 LDAP_BEGIN_DECL
30
31 typedef struct rdwr_var {
32         int readers_reading;
33         int writer_writing;
34         pthread_mutex_t mutex;
35         pthread_cond_t lock_free;
36 } pthread_rdwr_t;
37
38 typedef void * pthread_rdwrattr_t;
39
40 #define pthread_rdwrattr_default NULL;
41
42 LDAP_F int pthread_rdwr_init_np LDAP_P((pthread_rdwr_t *rdwrp, pthread_rdwrattr_t *attrp));
43 LDAP_F int pthread_rdwr_rlock_np LDAP_P((pthread_rdwr_t *rdwrp));
44 LDAP_F int pthread_rdwr_runlock_np LDAP_P((pthread_rdwr_t *rdwrp));
45 LDAP_F int pthread_rdwr_wlock_np LDAP_P((pthread_rdwr_t *rdwrp));
46 LDAP_F int pthread_rdwr_wunlock_np LDAP_P((pthread_rdwr_t *rdwrp));
47
48 #ifdef LDAP_DEBUG
49 LDAP_F int pthread_rdwr_rchk_np LDAP_P((pthread_rdwr_t *rdwrp));
50 LDAP_F int pthread_rdwr_wchk_np LDAP_P((pthread_rdwr_t *rdwrp));
51 LDAP_F int pthread_rdwr_rwchk_np LDAP_P((pthread_rdwr_t *rdwrp));
52 #endif /* LDAP_DEBUG */
53
54 LDAP_END_DECL
55
56 #endif /* _LTHREAD_RDWR_H */