libnx
rwlock.h
Go to the documentation of this file.
1 /**
2  * @file rwlock.h
3  * @brief Read/write lock synchronization primitive.
4  * @author plutoo
5  * @copyright libnx Authors
6  */
7 #pragma once
8 #include "../kernel/mutex.h"
9 
10 /// Read/write lock structure.
11 typedef struct {
12  RMutex r;
13  RMutex g;
14  u64 b;
15 } RwLock;
16 
17 /**
18  * @brief Locks the read/write lock for reading.
19  * @param r Read/write lock object.
20  */
21 void rwlockReadLock(RwLock* r);
22 
23 /**
24  * @brief Unlocks the read/write lock for reading.
25  * @param r Read/write lock object.
26  */
27 void rwlockReadUnlock(RwLock* r);
28 
29 /**
30  * @brief Locks the read/write lock for writing.
31  * @param r Read/write lock object.
32  */
33 void rwlockWriteLock(RwLock* r);
34 
35 /**
36  * @brief Unlocks the read/write lock for writing.
37  * @param r Read/write lock object.
38  */
39 void rwlockWriteUnlock(RwLock* r);
_LOCK_RECURSIVE_T RMutex
Recursive mutex datatype, defined in newlib.
Definition: mutex.h:14
void rwlockReadLock(RwLock *r)
Locks the read/write lock for reading.
void rwlockWriteLock(RwLock *r)
Locks the read/write lock for writing.
Read/write lock structure.
Definition: rwlock.h:11
uint64_t u64
64-bit unsigned integer.
Definition: types.h:24
void rwlockReadUnlock(RwLock *r)
Unlocks the read/write lock for reading.
void rwlockWriteUnlock(RwLock *r)
Unlocks the read/write lock for writing.