picotm
0.7.0
|
A reader-writer lock. More...
#include <picotm-lib-rwlock.h>
Data Fields | |
atomic_uint_least8_t | n |
The struct picotm_rwlock
data structure implements a reader-writer lock. Each instance can only be acquired at most once by each transaction. The implementation does not track which transactions acquired the lock, so transactions have to ensure that they acquire each lock at most once.
Before using an instance of struct picotm_rwlock
, initialize as show below.
The function picotm_rwlock_init()
cannot fail. All fields of the structure are private.
Likewise, uninitialize with picotm_rwlock_uninit()
as shown below.
The function picotm_rwlock_try_rdlock()
acquires a reader lock. With too many readers, the function fails with a conflict. You should always check the error parameter and perform recovery if necessary.
The function picotm_rwlock_try_wrlock()
acquires a writer lock, or upgrades a transaction's reader lock to a writer lock. With concurrent users, the function fails with a conflict. A reader lock can be updated to a writer lock at most once.
As with picotm_rwlock_try_rdlock()
, you should always check the error parameter and perform recovery if necessary.
atomic_uint_least8_t picotm_rwlock::n |
counter variable