Definition in file rwlock.h.
#include "lib/sectionlock.h"
#include "lib/lockerror.h"
#include <pthread.h>
#include <time.h>
#include <nobug.h>


Go to the source code of this file.
Classes | |
| struct | lumiera_rwlock_struct |
| RWLock. More... | |
Defines | |
| #define | LUMIERA_RDLOCK_SECTION(nobugflag, rwlck) |
| Read locked section. | |
| #define | LUMIERA_RDLOCK_SECTION_CHAIN(nobugflag, rwlck) |
| #define | LUMIERA_RWLOCK_SECTION_UNLOCK LUMIERA_SECTION_UNLOCK_(&lumiera_lock_section_) |
| #define | LUMIERA_WRLOCK_SECTION(nobugflag, rwlck) |
| Write locked section. | |
| #define | LUMIERA_WRLOCK_SECTION_CHAIN(nobugflag, rwlck) |
Typedefs | |
|
typedef struct lumiera_rwlock_struct | lumiera_rwlock |
| typedef lumiera_rwlock * | LumieraRWLock |
Functions | |
| LumieraRWLock | lumiera_rwlock_destroy (LumieraRWLock self, struct nobug_flag *flag, const struct nobug_context ctx) |
| destroy a rwlock | |
| LumieraRWLock | lumiera_rwlock_init (LumieraRWLock self, const char *purpose, struct nobug_flag *flag, const struct nobug_context ctx) |
| Initialize a rwlock. | |
| static LumieraRWLock | lumiera_rwlock_rdlock (LumieraRWLock self, struct nobug_flag *flag, struct nobug_resource_user **handle, const struct nobug_context ctx) |
| static LumieraRWLock | lumiera_rwlock_timedrdlock (LumieraRWLock self, const struct timespec *timeout, struct nobug_flag *flag, struct nobug_resource_user **handle, const struct nobug_context ctx) |
| static LumieraRWLock | lumiera_rwlock_timedwrlock (LumieraRWLock self, const struct timespec *timeout, struct nobug_flag *flag, struct nobug_resource_user **handle, const struct nobug_context ctx) |
| static LumieraRWLock | lumiera_rwlock_tryrdlock (LumieraRWLock self, struct nobug_flag *flag, struct nobug_resource_user **handle, const struct nobug_context ctx) |
| static LumieraRWLock | lumiera_rwlock_trywrlock (LumieraRWLock self, struct nobug_flag *flag, struct nobug_resource_user **handle, const struct nobug_context ctx) |
| static void | lumiera_rwlock_unlock (LumieraRWLock self, struct nobug_flag *flag, struct nobug_resource_user **handle, const struct nobug_context ctx) |
| static LumieraRWLock | lumiera_rwlock_wrlock (LumieraRWLock self, struct nobug_flag *flag, struct nobug_resource_user **handle, const struct nobug_context ctx) |
| #define LUMIERA_RDLOCK_SECTION | ( | nobugflag, | |||
| rwlck | ) |
Value:
for (lumiera_sectionlock NOBUG_CLEANUP(lumiera_sectionlock_ensureunlocked) \ lumiera_lock_section_ = { \ rwlck, (lumiera_sectionlock_unlock_fn) lumiera_rwlock_unlock \ NOBUG_ALPHA_COMMA(&NOBUG_FLAG(nobugflag)) NOBUG_ALPHA_COMMA_NULL}; \ ({ \ if (lumiera_lock_section_.lock) \ lumiera_lock_section_.lock = \ lumiera_rwlock_rdlock (rwlck, &NOBUG_FLAG(nobugflag), \ &lumiera_lock_section_.rh, NOBUG_CONTEXT); \ lumiera_lock_section_.lock; \ }); \ ({ \ LUMIERA_RWLOCK_SECTION_UNLOCK; \ }))
readlocks may fail when there are too much readers, one has to check the error afterwards!
| #define LUMIERA_RDLOCK_SECTION_CHAIN | ( | nobugflag, | |||
| rwlck | ) |
Value:
for (lumiera_sectionlock *lumiera_lock_section_old_ = &lumiera_lock_section_, \ NOBUG_CLEANUP(lumiera_sectionlock_ensureunlocked) lumiera_lock_section_ = { \ rwlck, (lumiera_sectionlock_unlock_fn) lumiera_rwlock_unlock \ NOBUG_ALPHA_COMMA(&NOBUG_FLAG(nobugflag)) NOBUG_ALPHA_COMMA_NULL}; \ ({ \ if (lumiera_lock_section_.lock) \ { \ REQUIRE (lumiera_lock_section_old_->lock, "section prematurely unlocked"); \ lumiera_lock_section_.lock = \ lumiera_rwlock_rdlock (rwlck, &NOBUG_FLAG(nobugflag), \ lumiera_lock_section_.rh, NOBUG_CONTEXT); \ LUMIERA_SECTION_UNLOCK_(lumiera_lock_section_old_); \ } \ lumiera_lock_section_.lock; \ }); \ ({ \ LUMIERA_RWLOCK_SECTION_UNLOCK; \ }))
| #define LUMIERA_WRLOCK_SECTION | ( | nobugflag, | |||
| rwlck | ) |
Value:
for (lumiera_sectionlock NOBUG_CLEANUP(lumiera_sectionlock_ensureunlocked) \ lumiera_lock_section_ = { \ rwlck, (lumiera_sectionlock_unlock_fn) lumiera_rwlock_unlock \ NOBUG_ALPHA_COMMA(&NOBUG_FLAG(nobugflag)) NOBUG_ALPHA_COMMA_NULL}; \ ({ \ if (lumiera_lock_section_.lock) \ lumiera_lock_section_.lock = \ lumiera_rwlock_wrlock (rwlck, &NOBUG_FLAG(nobugflag), \ &lumiera_lock_section_.rh, NOBUG_CONTEXT); \ lumiera_lock_section_.lock; \ }); \ ({ \ LUMIERA_RWLOCK_SECTION_UNLOCK; \ }))
| #define LUMIERA_WRLOCK_SECTION_CHAIN | ( | nobugflag, | |||
| rwlck | ) |
Value:
for (lumiera_sectionlock *lumiera_lock_section_old_ = &lumiera_lock_section_, \ NOBUG_CLEANUP(lumiera_sectionlock_ensureunlocked) lumiera_lock_section_ = { \ rwlck, (lumiera_sectionlock_unlock_fn) lumiera_rwlock_unlock \ NOBUG_ALPHA_COMMA(&NOBUG_FLAG(nobugflag)) NOBUG_ALPHA_COMMA_NULL}; \ ({ \ if (lumiera_lock_section_.lock) \ { \ REQUIRE (lumiera_lock_section_old_->lock, "section prematurely unlocked"); \ lumiera_lock_section_.lock = \ lumiera_rwlock_wrlock (rwlck, &NOBUG_FLAG(nobugflag), \ lumiera_lock_section_.rh, NOBUG_CONTEXT); \ LUMIERA_SECTION_UNLOCK_(lumiera_lock_section_old_); \ } \ lumiera_lock_section_.lock; \ }); \ ({ \ LUMIERA_RWLOCK_SECTION_UNLOCK; \ }))
| LumieraRWLock lumiera_rwlock_init | ( | LumieraRWLock | self, | |
| const char * | purpose, | |||
| struct nobug_flag * | flag, | |||
| const struct nobug_context | ctx | |||
| ) |
Initialize a rwlock.
| self | is a pointer to the rwlock to be initialized |
Definition at line 32 of file rwlock.c.
Referenced by lumiera_filedescriptor_new().

| LumieraRWLock lumiera_rwlock_destroy | ( | LumieraRWLock | self, | |
| struct nobug_flag * | flag, | |||
| const struct nobug_context | ctx | |||
| ) |
destroy a rwlock
| self | is a pointer to the rwlock to be initialized |
Definition at line 50 of file rwlock.c.
References LUMIERA_DIE.
Referenced by lumiera_filedescriptor_delete().

1.5.6