picotm  0.9.0
Data Structures | Macros | Functions
picotm-lib-rwlock.h File Reference
#include <stdatomic.h>
#include <stdbool.h>
#include "compiler.h"

Data Structures

struct  picotm_rwlock
 A reader-writer lock. More...
 

Macros

#define PICOTM_RWLOCK_INITIALIZER
 Initializer macro for R/W state variables.
 

Functions

PICOTM_NOTHROW void picotm_rwlock_init (struct picotm_rwlock *self)
 
PICOTM_NOTHROW void picotm_rwlock_try_rdlock (struct picotm_rwlock *self, struct picotm_error *error)
 
PICOTM_NOTHROW void picotm_rwlock_try_wrlock (struct picotm_rwlock *self, bool upgrade, struct picotm_error *error)
 
PICOTM_NOTHROW void picotm_rwlock_uninit (struct picotm_rwlock *self)
 
PICOTM_NOTHROW void picotm_rwlock_unlock (struct picotm_rwlock *self)
 

Function Documentation

◆ picotm_rwlock_init()

PICOTM_NOTHROW void picotm_rwlock_init ( struct picotm_rwlock self)

Initializes a reader-writer lock.

Parameters
selfThe reader-writer lock to initialize.

◆ picotm_rwlock_try_rdlock()

PICOTM_NOTHROW void picotm_rwlock_try_rdlock ( struct picotm_rwlock self,
struct picotm_error error 
)

Tries to acquire a read lock. If the lock could not be acquired, the error parameter will return a conflict.

Parameters
selfThe reader lock to acquire.
[out]errorReturns a error.

◆ picotm_rwlock_try_wrlock()

PICOTM_NOTHROW void picotm_rwlock_try_wrlock ( struct picotm_rwlock self,
bool  upgrade,
struct picotm_error error 
)

Tries to acquire a writer lock or upgrade an acquired reader lock to a writer lock. If the lock could not be acquired, the error parameter will return a conflict.

Parameters
selfThe writer lock to acquire.
upgradeTrue to upgrade a previously acquired reader lock.
[out]errorReturns a error.

◆ picotm_rwlock_uninit()

PICOTM_NOTHROW void picotm_rwlock_uninit ( struct picotm_rwlock self)

Uninitializes a reader-writer lock.

Parameters
selfThe reader-writer lock to uninitialize.

◆ picotm_rwlock_unlock()

PICOTM_NOTHROW void picotm_rwlock_unlock ( struct picotm_rwlock self)

Releases a reader-writer lock.

Parameters
selfThe reader-writer lock to release.