IDZEBRA  2.2.7
zebra-lock.h
Go to the documentation of this file.
1 /* This file is part of the Zebra server.
2  Copyright (C) Index Data
3 
4 Zebra is free software; you can redistribute it and/or modify it under
5 the terms of the GNU General Public License as published by the Free
6 Software Foundation; either version 2, or (at your option) any later
7 version.
8 
9 Zebra is distributed in the hope that it will be useful, but WITHOUT ANY
10 WARRANTY; without even the implied warranty of MERCHANTABILITY or
11 FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License
12 for more details.
13 
14 You should have received a copy of the GNU General Public License
15 along with this program; if not, write to the Free Software
16 Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA
17 
18 */
19 
20 
21 
22 #ifndef ZEBRA_LOCK_H
23 #define ZEBRA_LOCK_H
24 
25 #ifdef WIN32
26 #include <windows.h>
27 #endif
28 #if YAZ_POSIX_THREADS
29 #include <pthread.h>
30 #endif
31 
32 #include <yaz/yconfig.h>
33 
34 YAZ_BEGIN_CDECL
35 
36 typedef struct {
37 #ifdef WIN32
38  CRITICAL_SECTION mutex;
39 #else
40 # if YAZ_POSIX_THREADS
41  pthread_mutex_t mutex;
42 # else
43  int dummy;
44 # endif
45 #endif
46  int state;
47 } Zebra_mutex;
48 
49 YAZ_EXPORT int zebra_mutex_init (Zebra_mutex *p);
50 YAZ_EXPORT int zebra_mutex_destroy (Zebra_mutex *p);
51 YAZ_EXPORT int zebra_mutex_lock (Zebra_mutex *p);
52 YAZ_EXPORT int zebra_mutex_unlock (Zebra_mutex *p);
53 
54 typedef struct {
57 #if YAZ_POSIX_THREADS
58  pthread_mutex_t mutex;
59  pthread_cond_t lock_free;
60 #endif
62 
63 YAZ_EXPORT int zebra_lock_rdwr_init (Zebra_lock_rdwr *p);
64 YAZ_EXPORT int zebra_lock_rdwr_destroy (Zebra_lock_rdwr *p);
65 YAZ_EXPORT int zebra_lock_rdwr_rlock (Zebra_lock_rdwr *p);
66 YAZ_EXPORT int zebra_lock_rdwr_wlock (Zebra_lock_rdwr *p);
67 YAZ_EXPORT int zebra_lock_rdwr_runlock (Zebra_lock_rdwr *p);
68 YAZ_EXPORT int zebra_lock_rdwr_wunlock (Zebra_lock_rdwr *p);
69 
70 typedef struct {
71 #if YAZ_POSIX_THREADS
72  pthread_mutex_t mutex;
73  pthread_cond_t cond;
74 #else
75  int dummy;
76 #endif
78 
79 YAZ_EXPORT int zebra_mutex_cond_init (Zebra_mutex_cond *p);
80 YAZ_EXPORT int zebra_mutex_cond_destroy (Zebra_mutex_cond *p);
81 YAZ_EXPORT int zebra_mutex_cond_lock (Zebra_mutex_cond *p);
82 YAZ_EXPORT int zebra_mutex_cond_unlock (Zebra_mutex_cond *p);
83 YAZ_EXPORT int zebra_mutex_cond_wait (Zebra_mutex_cond *p);
84 YAZ_EXPORT int zebra_mutex_cond_signal (Zebra_mutex_cond *p);
85 
86 YAZ_END_CDECL
87 
88 #endif
89 /*
90  * Local variables:
91  * c-basic-offset: 4
92  * c-file-style: "Stroustrup"
93  * indent-tabs-mode: nil
94  * End:
95  * vim: shiftwidth=4 tabstop=8 expandtab
96  */
97 
int zebra_mutex_cond_init(Zebra_mutex_cond *p)
Definition: zebra-lock.c:174
int zebra_mutex_unlock(Zebra_mutex *p)
Definition: zebra-lock.c:74
int zebra_mutex_init(Zebra_mutex *p)
Definition: zebra-lock.c:31
int zebra_mutex_cond_lock(Zebra_mutex_cond *p)
Definition: zebra-lock.c:192
int zebra_lock_rdwr_rlock(Zebra_lock_rdwr *p)
Definition: zebra-lock.c:111
int zebra_lock_rdwr_wlock(Zebra_lock_rdwr *p)
Definition: zebra-lock.c:123
int zebra_mutex_cond_unlock(Zebra_mutex_cond *p)
Definition: zebra-lock.c:201
int zebra_lock_rdwr_destroy(Zebra_lock_rdwr *p)
Definition: zebra-lock.c:100
int zebra_mutex_cond_destroy(Zebra_mutex_cond *p)
Definition: zebra-lock.c:183
int zebra_lock_rdwr_wunlock(Zebra_lock_rdwr *p)
Definition: zebra-lock.c:155
int zebra_lock_rdwr_runlock(Zebra_lock_rdwr *p)
Definition: zebra-lock.c:135
int zebra_mutex_lock(Zebra_mutex *p)
Definition: zebra-lock.c:59
int zebra_mutex_cond_signal(Zebra_mutex_cond *p)
Definition: zebra-lock.c:219
int zebra_mutex_cond_wait(Zebra_mutex_cond *p)
Definition: zebra-lock.c:210
int zebra_lock_rdwr_init(Zebra_lock_rdwr *p)
Definition: zebra-lock.c:89
int zebra_mutex_destroy(Zebra_mutex *p)
Definition: zebra-lock.c:43