libguac 1.5.5
Loading...
Searching...
No Matches
Data Fields
guac_rwlock Struct Reference

This file implements reentrant read-write locks using thread-local storage to keep track of how locks are held and released by the current thread, since the pthread locks do not support reentrant behavior. More...

#include <rwlock.h>

Data Fields

pthread_rwlock_t lock
 A non-reentrant pthread rwlock to be wrapped by the local lock, functions providing reentrant behavior.
 
pthread_key_t key
 A key to access a thread-local property tracking any ownership of the lock by the current thread.
 

Detailed Description

This file implements reentrant read-write locks using thread-local storage to keep track of how locks are held and released by the current thread, since the pthread locks do not support reentrant behavior.

A thread will attempt to acquire the requested lock on the first acquire function call, and will release it once the number of unlock requests matches the number of lock requests. Therefore, it is safe to acquire a lock and then call a function that also acquires the same lock, provided that the caller and the callee request to unlock the lock when done with it.

Any lock that's locked using one of the functions defined in this file must only be unlocked using the unlock function defined here to avoid unexpected behavior. A structure packaging together a pthread rwlock along with a key to a thread-local property to keep track of the current status of the lock, allowing the functions defined in this header to provide reentrant behavior. Note that both the lock and key must be initialized before being provided to any of these functions.


The documentation for this struct was generated from the following file: