Definition in file mutex.h.
#include "lib/error.h"
#include <pthread.h>
#include <nobug.h>


Go to the source code of this file.
Classes | |
| struct | lumiera_mutex_struct |
| Mutex. More... | |
| struct | lumiera_mutexacquirer_struct |
| mutexacquirer used to manage the state of a mutex. More... | |
Defines | |
| #define | LUMIERA_MUTEX_SECTION(nobugflag, mtx) |
| Mutual exclusive section. | |
| #define | LUMIERA_MUTEX_SECTION_CHAIN(nobugflag, mtx) |
| Mutual exclusion chainbuilder section. | |
| #define | LUMIERA_RECMUTEX_SECTION(nobugflag, mtx) |
| Recursive Mutual exclusive section. | |
| #define | LUMIERA_RECMUTEX_SECTION_CHAIN(nobugflag, mtx) |
| Mutual exclusion chainbuilder section. | |
Typedefs | |
| typedef struct lumiera_mutex_struct | lumiera_mutex |
|
typedef struct lumiera_mutexacquirer_struct | lumiera_mutexacquirer |
| typedef lumiera_mutex * | LumieraMutex |
|
typedef struct lumiera_mutexacquirer_struct * | LumieraMutexacquirer |
Functions | |
| LUMIERA_ERROR_DECLARE (MUTEX_DESTROY) | |
| LUMIERA_ERROR_DECLARE (MUTEX_UNLOCK) | |
| LUMIERA_ERROR_DECLARE (MUTEX_LOCK) | |
| LumieraMutex | lumiera_mutex_destroy (LumieraMutex self, struct nobug_flag *flag) |
| Destroy a mutex variable. | |
| LumieraMutex | lumiera_mutex_init (LumieraMutex self, const char *purpose, struct nobug_flag *flag) |
| Initialize a mutex variable This initializes a 'fast' default mutex which must not be locked recursively from one thread. | |
| static void | lumiera_mutexacquirer_ensureunlocked (LumieraMutexacquirer self) |
| LumieraMutex | lumiera_recmutex_init (LumieraMutex self, const char *purpose, struct nobug_flag *flag) |
| Initialize a mutex variable Initializes a 'recursive' mutex which might be locked by the same thread multiple times. | |
| #define LUMIERA_MUTEX_SECTION | ( | nobugflag, | |||
| mtx | ) |
Value:
for (lumiera_mutexacquirer NOBUG_CLEANUP(lumiera_mutexacquirer_ensureunlocked) lumiera_mutex_section_ \ = {(LumieraMutex)1 NOBUG_ALPHA_COMMA_NULL}; \ lumiera_mutex_section_.mutex;) \ for ( \ ({ \ lumiera_mutex_section_.mutex = (mtx); \ NOBUG_RESOURCE_HANDLE_INIT (lumiera_mutex_section_.rh); \ RESOURCE_ENTER (nobugflag, (mtx)->rh, "acquire mutex", &lumiera_mutex_section_, \ NOBUG_RESOURCE_EXCLUSIVE, lumiera_mutex_section_.rh); \ if (pthread_mutex_lock (&(mtx)->mutex)) LUMIERA_DIE (MUTEX_LOCK); \ }); \ lumiera_mutex_section_.mutex; \ ({ \ if (lumiera_mutex_section_.mutex) \ { \ pthread_mutex_unlock (&lumiera_mutex_section_.mutex->mutex); \ lumiera_mutex_section_.mutex = NULL; \ RESOURCE_LEAVE(nobugflag, lumiera_mutex_section_.rh); \ } \ }))
Definition at line 42 of file mutex.h.
Referenced by lumiera_config_number_get(), lumiera_config_setdefault(), lumiera_config_wordlist_add(), lumiera_config_wordlist_get(), lumiera_config_wordlist_replace(), lumiera_filedescriptor_acquire(), lumiera_filedescriptor_delete(), lumiera_filedescriptor_release(), lumiera_filehandlecache_checkin(), lumiera_filehandlecache_checkout(), lumiera_filehandlecache_handle_acquire(), lumiera_mmapcache_announce(), lumiera_mmapcache_checkin(), lumiera_mmapcache_checkout(), lumiera_mmapcache_forget(), lumiera_mmapcache_mmap_acquire(), lumiera_mmapings_mmap_acquire(), and lumiera_mmapings_release_mmap().
| #define LUMIERA_MUTEX_SECTION_CHAIN | ( | nobugflag, | |||
| mtx | ) |
Value:
for (lumiera_mutexacquirer *lumiera_mutex_section_old_ = &lumiera_mutex_section_, \ NOBUG_CLEANUP(lumiera_mutexacquirer_ensureunlocked) lumiera_mutex_section_ = {(LumieraMutex)1 \ NOBUG_ALPHA_COMMA_NULL}; \ lumiera_mutex_section_.mutex;) \ for ( \ ({ \ lumiera_mutex_section_.mutex = (mtx); \ NOBUG_RESOURCE_HANDLE_INIT (lumiera_mutex_section_.rh); \ RESOURCE_ENTER (nobugflag, (mtx)->rh, "acquire mutex", &lumiera_mutex_section_, \ NOBUG_RESOURCE_EXCLUSIVE, lumiera_mutex_section_.rh); \ if (pthread_mutex_lock (&(mtx)->mutex)) LUMIERA_DIE (MUTEX_LOCK); \ if (lumiera_mutex_section_old_->mutex) \ { \ pthread_mutex_unlock (&lumiera_mutex_section_old_->mutex->mutex); \ lumiera_mutex_section_old_->mutex = NULL; \ RESOURCE_LEAVE(nobugflag, lumiera_mutex_section_old_->rh); \ } \ }); \ lumiera_mutex_section_.mutex; \ ({ \ if (lumiera_mutex_section_.mutex) \ { \ pthread_mutex_unlock (&lumiera_mutex_section_.mutex->mutex); \ lumiera_mutex_section_.mutex = NULL; \ RESOURCE_LEAVE(nobugflag, lumiera_mutex_section_.rh); \ } \ }))
Usage: LUMIERA_MUTEX_SECTION(a){LUMIERA_MUTEX_SECTION_CHAIN(b){run();}} calls lock(a); lock(b); unlock(a); run(); unlock(b); This macro should only be used inside LUMIERA_MUTEX_SECTION and should be called on the correct mutexes, period.
| #define LUMIERA_RECMUTEX_SECTION | ( | nobugflag, | |||
| mtx | ) |
Value:
for (lumiera_mutexacquirer NOBUG_CLEANUP(lumiera_mutexacquirer_ensureunlocked) lumiera_mutex_section_ \ = {(LumieraMutex)1 NOBUG_ALPHA_COMMA_NULL}; \ lumiera_mutex_section_.mutex;) \ for ( \ ({ \ lumiera_mutex_section_.mutex = (mtx); \ NOBUG_RESOURCE_HANDLE_INIT (lumiera_mutex_section_.rh); \ RESOURCE_ENTER (nobugflag, (mtx)->rh, "acquire recmutex", &lumiera_mutex_section_, \ NOBUG_RESOURCE_RECURSIVE, lumiera_mutex_section_.rh); \ if (pthread_mutex_lock (&(mtx)->mutex)) LUMIERA_DIE (MUTEX_LOCK); \ }); \ lumiera_mutex_section_.mutex; \ ({ \ if (lumiera_mutex_section_.mutex) \ { \ pthread_mutex_unlock (&lumiera_mutex_section_.mutex->mutex); \ lumiera_mutex_section_.mutex = NULL; \ RESOURCE_LEAVE(nobugflag, lumiera_mutex_section_.rh); \ } \ }))
Definition at line 104 of file mutex.h.
Referenced by lumiera_interface_close(), lumiera_interface_open(), lumiera_plugin_discover(), lumiera_plugin_lookup(), lumiera_plugin_register(), and lumiera_plugin_unload().
| #define LUMIERA_RECMUTEX_SECTION_CHAIN | ( | nobugflag, | |||
| mtx | ) |
Value:
for (lumiera_mutexacquirer *lumiera_mutex_section_old_ = &lumiera_mutex_section_, \ NOBUG_CLEANUP(lumiera_mutexacquirer_ensureunlocked) lumiera_mutex_section_ = {(LumieraMutex)1 \ NOBUG_ALPHA_COMMA_NULL}; \ lumiera_mutex_section_.mutex;) \ for ( \ ({ \ lumiera_mutex_section_.mutex = (mtx); \ NOBUG_RESOURCE_HANDLE_INIT (lumiera_mutex_section_.rh); \ RESOURCE_ENTER (nobugflag, (mtx)->rh, "acquire recmutex", &lumiera_mutex_section_, \ NOBUG_RESOURCE_RECURSIVE, lumiera_mutex_section_.rh); \ if (pthread_mutex_lock (&(mtx)->mutex)) LUMIERA_DIE (MUTEX_LOCK); \ if (lumiera_mutex_section_old_->mutex) \ { \ pthread_mutex_unlock (&lumiera_mutex_section_old_->mutex->mutex); \ lumiera_mutex_section_old_->mutex = NULL; \ RESOURCE_LEAVE(nobugflag, lumiera_mutex_section_old_->rh); \ } \ }); \ lumiera_mutex_section_.mutex; \ ({ \ if (lumiera_mutex_section_.mutex) \ { \ pthread_mutex_unlock (&lumiera_mutex_section_.mutex->mutex); \ lumiera_mutex_section_.mutex = NULL; \ RESOURCE_LEAVE(nobugflag, lumiera_mutex_section_.rh); \ } \ }))
Usage: LUMIERA_MUTEX_SECTION(a){LUMIERA_RECMUTEX_SECTION_CHAIN(b){run();}} calls lock(a); lock(b); unlock(a); run(); unlock(b); This macro should only be used inside LUMIERA_MUTEX_SECTION and should be called on the correct mutexes, period.
| LumieraMutex lumiera_mutex_init | ( | LumieraMutex | self, | |
| const char * | purpose, | |||
| struct nobug_flag * | flag | |||
| ) |
Initialize a mutex variable This initializes a 'fast' default mutex which must not be locked recursively from one thread.
| self | is a pointer to the mutex to be initialized |
Definition at line 35 of file mutex.c.
Referenced by lumiera_config_init(), lumiera_filedescriptor_new(), lumiera_filedescriptor_registry_init(), lumiera_filehandlecache_new(), lumiera_mmapcache_new(), and lumiera_mmapings_init().

| LumieraMutex lumiera_recmutex_init | ( | LumieraMutex | self, | |
| const char * | purpose, | |||
| struct nobug_flag * | flag | |||
| ) |
Initialize a mutex variable Initializes a 'recursive' mutex which might be locked by the same thread multiple times.
| self | is a pointer to the mutex to be initialized |
Definition at line 58 of file mutex.c.
Referenced by lumiera_interfaceregistry_init().

| LumieraMutex lumiera_mutex_destroy | ( | LumieraMutex | self, | |
| struct nobug_flag * | flag | |||
| ) |
Destroy a mutex variable.
| self | is a pointer to the mutex to be destroyed |
Definition at line 74 of file mutex.c.
References LUMIERA_DIE.
Referenced by lumiera_config_destroy(), lumiera_filedescriptor_delete(), lumiera_filedescriptor_registry_destroy(), lumiera_filehandlecache_delete(), lumiera_mmapcache_delete(), and lumiera_mmapings_destroy().

1.5.6