Read-Write Mutex.
More...
Read-Write Mutex.
|
| #define | RWMUTEX_READ_SCOPE(mutex) |
| | Acquires a rwmutex for reading for the reminder of the current scope.
|
| |
| #define | RWMUTEX_WRITE_SCOPE(mutex) |
| | Acquires a rwmutex for writing for the reminder of the current scope.
|
| |
| #define | RWMUTEX_CREATE(name) |
| | Create a rwmutex initializer.
|
| |
◆ RWMUTEX_READ_SCOPE
| #define RWMUTEX_READ_SCOPE |
( |
|
mutex | ) |
|
Value:
rwmutex_read_acquire((mutex))
static void rwmutex_read_cleanup(rwmutex_t **mutex)
#define CONCAT(a, b)
Concatenates two tokens.
Read-Write Mutex structure.
Acquires a rwmutex for reading for the reminder of the current scope.
- Parameters
-
| mutex | Pointer to the rwmutex to acquire. |
Definition at line 21 of file rwmutex.h.
◆ RWMUTEX_WRITE_SCOPE
| #define RWMUTEX_WRITE_SCOPE |
( |
|
mutex | ) |
|
Value:
rwmutex_write_acquire((mutex))
static void rwmutex_write_cleanup(rwmutex_t **mutex)
Acquires a rwmutex for writing for the reminder of the current scope.
- Parameters
-
| mutex | Pointer to the rwmutex to acquire. |
Definition at line 30 of file rwmutex.h.
◆ RWMUTEX_CREATE
| #define RWMUTEX_CREATE |
( |
|
name | ) |
|
Value: { \
.activeReaders = 0, \
.waitingWriters = 0, \
.hasWriter = false, \
}
#define WAIT_QUEUE_CREATE(name)
Create a wait queue initializer.
#define LOCK_CREATE()
Create a lock initializer.
Create a rwmutex initializer.
- Parameters
-
| name | The name of the rwmutex variable to initialize. |
- Returns
- A
rwmutex_t initializer.
Definition at line 58 of file rwmutex.h.
◆ rwmutex_init()
Initializes a rwmutex.
- Parameters
-
| mtx | Pointer to the rwmutex to initialize. |
Definition at line 10 of file rwmutex.c.
◆ rwmutex_deinit()
Deinitializes a rwmutex.
- Parameters
-
| mtx | Pointer to the rwmutex to deinitialize. |
Definition at line 20 of file rwmutex.c.
◆ rwmutex_read_acquire()
Acquires a rwmutex for reading, blocking until it is available.
- Parameters
-
| mtx | Pointer to the rwmutex to acquire. |
Definition at line 30 of file rwmutex.c.
◆ rwmutex_read_try_acquire()
Tries to acquire a rwmutex for reading.
If the rwmutex is owned by another thread for writing or a writer is waiting, this function will fail with EWOULDBLOCK.
If the function succeeds, rwmutex_read_release() must be called to release the rwmutex.
- Parameters
-
| mtx | Pointer to the rwmutex to acquire. |
- Returns
- On success,
0. On error, ERR and errno is set.
Definition at line 47 of file rwmutex.c.
◆ rwmutex_read_release()
Releases a rwmutex from reading.
- Parameters
-
| mtx | Pointer to the rwmutex to release. |
Definition at line 67 of file rwmutex.c.
◆ rwmutex_write_acquire()
| void rwmutex_write_acquire |
( |
rwmutex_t * |
mtx | ) |
|
Acquires a rwmutex for writing, blocking until it is available.
- Parameters
-
| mtx | Pointer to the rwmutex to acquire. |
Definition at line 85 of file rwmutex.c.
◆ rwmutex_write_try_acquire()
Tries to acquire a rwmutex for writing.
If the function succeeds, rwmutex_write_release() must be called to release the rwmutex.
- Parameters
-
| mtx | Pointer to the rwmutex to acquire. |
- Returns
- On success,
0. On error, ERR and errno is set.
Definition at line 104 of file rwmutex.c.
◆ rwmutex_write_release()
| void rwmutex_write_release |
( |
rwmutex_t * |
mtx | ) |
|
Releases a rwmutex from writing.
- Parameters
-
| mtx | Pointer to the rwmutex to release. |
Definition at line 124 of file rwmutex.c.
◆ rwmutex_read_cleanup()
| static void rwmutex_read_cleanup |
( |
rwmutex_t ** |
mutex | ) |
|
|
inlinestatic |
◆ rwmutex_write_cleanup()
| static void rwmutex_write_cleanup |
( |
rwmutex_t ** |
mutex | ) |
|
|
inlinestatic |