Lumiera  0.pre.03
»edit your freedom«
recmutex.h File Reference

Go to the source code of this file.

Description

Mutual exclusion locking, header.

Definition in file recmutex.h.

#include "lib/error.h"
#include "lib/sectionlock.h"
#include "lib/lockerror.h"
#include "lib/mutex.h"
#include <pthread.h>
#include <nobug.h>

Classes

struct  lumiera_recmutex
 Recursive Mutex. More...
 

Typedefs

typedef lumiera_recmutex * LumieraRecmutex
 

Macros

#define LUMIERA_RECMUTEX_SECTION(nobugflag, mtx)
 Recursive Mutual exclusive section. More...
 
#define LUMIERA_RECMUTEX_SECTION_CHAIN(nobugflag, mtx)
 
#define LUMIERA_RECMUTEX_SECTION_UNLOCK   LUMIERA_SECTION_UNLOCK_(&lumiera_lock_section_)
 

Functions

LumieraRecmutex lumiera_recmutex_destroy (LumieraRecmutex self, struct nobug_flag *flag, const struct nobug_context ctx)
 Destroy a recursive mutex variable. More...
 
LumieraRecmutex lumiera_recmutex_init (LumieraRecmutex self, const char *purpose, struct nobug_flag *flag, const struct nobug_context ctx)
 Initialise a recursive mutex variable Initialises a 'recursive' mutex which might be locked by the same thread multiple times. More...
 
static LumieraRecmutex lumiera_recmutex_lock (LumieraRecmutex self, struct nobug_flag *flag, struct nobug_resource_user **handle, const struct nobug_context ctx)
 
static LumieraRecmutex lumiera_recmutex_timedlock (LumieraRecmutex self, const struct timespec *timeout, struct nobug_flag *flag, struct nobug_resource_user **handle, const struct nobug_context ctx)
 
static LumieraRecmutex lumiera_recmutex_trylock (LumieraRecmutex self, struct nobug_flag *flag, struct nobug_resource_user **handle, const struct nobug_context ctx)
 
static void lumiera_recmutex_unlock (LumieraRecmutex self, struct nobug_flag *flag, struct nobug_resource_user **handle, const struct nobug_context ctx)
 

Macro Definition Documentation

◆ LUMIERA_RECMUTEX_SECTION

#define LUMIERA_RECMUTEX_SECTION (   nobugflag,
  mtx 
)
Value:
for (lumiera_sectionlock NOBUG_CLEANUP(lumiera_sectionlock_ensureunlocked) \
lumiera_lock_section_ = { \
mtx, (lumiera_sectionlock_unlock_fn) lumiera_mutex_unlock \
NOBUG_ALPHA_COMMA(&NOBUG_FLAG(nobugflag)) NOBUG_ALPHA_COMMA_NULL}; \
({ \
if (lumiera_lock_section_.lock) \
lumiera_lock_section_.lock = \
lumiera_recmutex_lock (mtx, &NOBUG_FLAG(nobugflag), \
&lumiera_lock_section_.rh, NOBUG_CONTEXT); \
lumiera_lock_section_.lock; \
}); \
({ \
LUMIERA_RECMUTEX_SECTION_UNLOCK; \
}))
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
Definition: mutex.h:239

Recursive Mutual exclusive section.

Definition at line 41 of file recmutex.h.

Referenced by lumiera_interface_close(), and lumiera_plugin_register().

◆ LUMIERA_RECMUTEX_SECTION_CHAIN

#define LUMIERA_RECMUTEX_SECTION_CHAIN (   nobugflag,
  mtx 
)
Value:
for (lumiera_sectionlock *lumiera_lock_section_old_ = &lumiera_lock_section_, \
NOBUG_CLEANUP(lumiera_sectionlock_ensureunlocked) lumiera_lock_section_ = { \
mtx, (lumiera_sectionlock_unlock_fn) lumiera_mutex_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_recmutex_lock (mtx, &NOBUG_FLAG(nobugflag), \
lumiera_lock_section_.rh, NOBUG_CONTEXT); \
LUMIERA_SECTION_UNLOCK_(lumiera_lock_section_old_); \
} \
lumiera_lock_section_.lock; \
}); \
({ \
LUMIERA_RECMUTEX_SECTION_UNLOCK; \
}))
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
Definition: mutex.h:239

Definition at line 58 of file recmutex.h.

Function Documentation

◆ lumiera_recmutex_init()

LumieraRecmutex lumiera_recmutex_init ( LumieraRecmutex  self,
const char *  purpose,
struct nobug_flag *  flag,
const struct nobug_context  ctx 
)

Initialise a recursive mutex variable Initialises a 'recursive' mutex which might be locked by the same thread multiple times.

Parameters
selfis a pointer to the mutex to be initialised
Returns
self as given

Definition at line 41 of file recmutex.c.

◆ lumiera_recmutex_destroy()

LumieraRecmutex lumiera_recmutex_destroy ( LumieraRecmutex  self,
struct nobug_flag *  flag,
const struct nobug_context  ctx 
)

Destroy a recursive mutex variable.

Parameters
selfis a pointer to the mutex to be destroyed
Returns
self as given

Definition at line 62 of file recmutex.c.

References LUMIERA_DIE.