IDZEBRA 2.2.8
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
4Zebra is free software; you can redistribute it and/or modify it under
5the terms of the GNU General Public License as published by the Free
6Software Foundation; either version 2, or (at your option) any later
7version.
8
9Zebra is distributed in the hope that it will be useful, but WITHOUT ANY
10WARRANTY; without even the implied warranty of MERCHANTABILITY or
11FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License
12for more details.
13
14You should have received a copy of the GNU General Public License
15along with this program; if not, write to the Free Software
16Foundation, 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
34YAZ_BEGIN_CDECL
35
36typedef 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;
48
49YAZ_EXPORT int zebra_mutex_init (Zebra_mutex *p);
50YAZ_EXPORT int zebra_mutex_destroy (Zebra_mutex *p);
51YAZ_EXPORT int zebra_mutex_lock (Zebra_mutex *p);
52YAZ_EXPORT int zebra_mutex_unlock (Zebra_mutex *p);
53
54typedef struct {
57#if YAZ_POSIX_THREADS
58 pthread_mutex_t mutex;
59 pthread_cond_t lock_free;
60#endif
62
63YAZ_EXPORT int zebra_lock_rdwr_init (Zebra_lock_rdwr *p);
65YAZ_EXPORT int zebra_lock_rdwr_rlock (Zebra_lock_rdwr *p);
66YAZ_EXPORT int zebra_lock_rdwr_wlock (Zebra_lock_rdwr *p);
69
70typedef struct {
71#if YAZ_POSIX_THREADS
72 pthread_mutex_t mutex;
73 pthread_cond_t cond;
74#else
75 int dummy;
76#endif
78
79YAZ_EXPORT int zebra_mutex_cond_init (Zebra_mutex_cond *p);
81YAZ_EXPORT int zebra_mutex_cond_lock (Zebra_mutex_cond *p);
83YAZ_EXPORT int zebra_mutex_cond_wait (Zebra_mutex_cond *p);
85
86YAZ_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