Make check works, no problems (yet) with threads
[pazpar2-moved-to-github.git] / src / ppmutex.h
1 /* This file is part of Pazpar2.
2    Copyright (C) 2006-2013 Index Data
3
4 Pazpar2 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 Pazpar2 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 /** \file
21     \brief control MUTEX debugging
22 */
23
24 #ifndef PAZPAR2_PPMUTEX_H
25 #define PAZPAR2_PPMUTEX_H
26
27 #include <yaz/mutex.h>
28
29 #if YAZ_POSIX_THREADS
30 #include <pthread.h>
31 #endif
32
33 void pazpar2_mutex_init(void);
34
35 void pazpar2_mutex_create(YAZ_MUTEX *p, const char *name);
36
37 typedef struct {
38     int readers_reading;
39     int writers_writing;
40 #if YAZ_POSIX_THREADS
41     pthread_mutex_t mutex;
42     pthread_cond_t lock_free;
43 #endif
44 } Pazpar2_lock_rdwr;
45
46 void pazpar2_lock_rdwr_init(Pazpar2_lock_rdwr *p);
47 void pazpar2_lock_rdwr_destroy(Pazpar2_lock_rdwr *p);
48 void pazpar2_lock_rdwr_rlock(Pazpar2_lock_rdwr *p);
49 void pazpar2_lock_rdwr_wlock(Pazpar2_lock_rdwr *p);
50 void pazpar2_lock_rdwr_runlock(Pazpar2_lock_rdwr *p);
51 void pazpar2_lock_rdwr_wunlock(Pazpar2_lock_rdwr *p);
52 void pazpar2_lock_rdwr_upgrade(Pazpar2_lock_rdwr *p);
53 void pazpar2_lock_rdwr_downgrade(Pazpar2_lock_rdwr *p);
54
55 #endif
56
57 /*
58  * Local variables:
59  * c-basic-offset: 4
60  * c-file-style: "Stroustrup"
61  * indent-tabs-mode: nil
62  * End:
63  * vim: shiftwidth=4 tabstop=8 expandtab
64  */
65