libguac  1.5.4
rwlock.h
1 /*
2  * Licensed to the Apache Software Foundation (ASF) under one
3  * or more contributor license agreements. See the NOTICE file
4  * distributed with this work for additional information
5  * regarding copyright ownership. The ASF licenses this file
6  * to you under the Apache License, Version 2.0 (the
7  * "License"); you may not use this file except in compliance
8  * with the License. You may obtain a copy of the License at
9  *
10  * http://www.apache.org/licenses/LICENSE-2.0
11  *
12  * Unless required by applicable law or agreed to in writing,
13  * software distributed under the License is distributed on an
14  * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
15  * KIND, either express or implied. See the License for the
16  * specific language governing permissions and limitations
17  * under the License.
18  */
19 
20 #ifndef __GUAC_RWLOCK_H
21 #define __GUAC_RWLOCK_H
22 
23 #include <pthread.h>
24 
48 typedef struct guac_rwlock {
49 
54  pthread_rwlock_t lock;
55 
60  pthread_key_t key;
61 
62 } guac_rwlock;
63 
71 void guac_rwlock_init(guac_rwlock* lock);
72 
79 void guac_rwlock_destroy(guac_rwlock* lock);
80 
99 int guac_rwlock_acquire_write_lock(guac_rwlock* reentrant_rwlock);
100 
118 int guac_rwlock_acquire_read_lock(guac_rwlock* reentrant_rwlock);
119 
136 int guac_rwlock_release_lock(guac_rwlock* reentrant_rwlock);
137 
138 #endif
139 
pthread_rwlock_t lock
A non-reentrant pthread rwlock to be wrapped by the local lock, functions providing reentrant behavio...
Definition: rwlock.h:54
This file implements reentrant read-write locks using thread-local storage to keep track of how locks...
Definition: rwlock.h:48
pthread_key_t key
A key to access a thread-local property tracking any ownership of the lock by the current thread...
Definition: rwlock.h:60