Lumiera
0.pre.03
»edit your freedom«
|
Go to the source code of this file.
Mutual exclusion locking, header.
Definition in file mutex.h.
#include "lib/error.h"
#include "lib/sectionlock.h"
#include "lib/lockerror.h"
#include <pthread.h>
#include <time.h>
#include <nobug.h>
Classes | |
struct | lumiera_mutex |
Mutex. More... | |
Typedefs | |
typedef lumiera_mutex * | LumieraMutex |
Macros | |
#define | LUMIERA_MUTEX_SECTION(nobugflag, mtx) |
Mutual exclusive section. More... | |
#define | LUMIERA_MUTEX_SECTION_CHAIN(nobugflag, mtx) |
Mutual exclusion chainbuilder section. More... | |
#define | LUMIERA_MUTEX_SECTION_UNLOCK LUMIERA_SECTION_UNLOCK_(&lumiera_lock_section_) |
Functions | |
LumieraMutex | lumiera_mutex_destroy (LumieraMutex self, struct nobug_flag *flag, const struct nobug_context ctx) |
Destroy a mutex variable. More... | |
LumieraMutex | lumiera_mutex_init (LumieraMutex self, const char *purpose, struct nobug_flag *flag, const struct nobug_context ctx) |
Initialise a mutex variable This initialises a 'fast' default mutex which must not be locked recursively from one thread. More... | |
static LumieraMutex | lumiera_mutex_lock (LumieraMutex self, struct nobug_flag *flag, struct nobug_resource_user **handle, const struct nobug_context ctx) |
Lock a mutex variable Never fails. More... | |
static LumieraMutex | lumiera_mutex_timedlock (LumieraMutex self, const struct timespec *timeout, struct nobug_flag *flag, struct nobug_resource_user **handle, const struct nobug_context ctx) |
Try to lock a mutex variable with a timeout. More... | |
static LumieraMutex | lumiera_mutex_trylock (LumieraMutex self, struct nobug_flag *flag, struct nobug_resource_user **handle, const struct nobug_context ctx) |
Try to lock a mutex variable. More... | |
static void | lumiera_mutex_unlock (LumieraMutex self, struct nobug_flag *flag, struct nobug_resource_user **handle, const struct nobug_context ctx) |
unlock a mutex variable Never fails More... | |
#define LUMIERA_MUTEX_SECTION | ( | nobugflag, | |
mtx | |||
) |
Mutual exclusive section.
#define LUMIERA_MUTEX_SECTION_CHAIN | ( | nobugflag, | |
mtx | |||
) |
Mutual exclusion chainbuilder section.
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.
LumieraMutex lumiera_mutex_init | ( | LumieraMutex | self, |
const char * | purpose, | ||
struct nobug_flag * | flag, | ||
const struct nobug_context | ctx | ||
) |
Initialise a mutex variable This initialises a 'fast' default mutex which must not be locked recursively from one thread.
self | is a pointer to the mutex to be initialised |
purpose | textual hint for the nobug resourcetracker |
flag | nobug logging target |
LumieraMutex lumiera_mutex_destroy | ( | LumieraMutex | self, |
struct nobug_flag * | flag, | ||
const struct nobug_context | ctx | ||
) |
Destroy a mutex variable.
self | is a pointer to the mutex to be destroyed |
flag | nobug logging target |
Definition at line 48 of file mutex.c.
References LUMIERA_DIE.
|
inlinestatic |
Lock a mutex variable Never fails.
self | is a pointer to the mutex to be destroyed |
flag | nobug logging target |
handle | pointer to nobug user handle (NULL in beta and release builds) |
Definition at line 138 of file mutex.h.
References LUMIERA_DIE.
|
inlinestatic |
Try to lock a mutex variable.
self | is a pointer to the mutex to be destroyed |
flag | nobug logging target |
handle | pointer to nobug user handle (NULL in beta and release builds) |
Definition at line 166 of file mutex.h.
References lumiera_lockerror_set().
|
inlinestatic |
Try to lock a mutex variable with a timeout.
self | is a pointer to the mutex to be destroyed |
timeout | timeout for waiting for the lock |
flag | nobug logging target |
handle | pointer to nobug user handle (NULL in beta and release builds) |
Definition at line 202 of file mutex.h.
References lumiera_lockerror_set().
|
inlinestatic |
unlock a mutex variable Never fails
self | is a pointer to the mutex to be destroyed |
flag | nobug logging target |
handle | pointer to nobug user handle (NULL in beta and release builds) |
Definition at line 239 of file mutex.h.
References LUMIERA_DIE.