Lumiera 0.pre.04~rc.1
»edit your freedom«
Loading...
Searching...
No Matches
recmutex.h File Reference

Mutual exclusion locking, header. More...

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>

Macros

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

Typedefs

typedef lumiera_recmutex * LumieraRecmutex
 

Classes

struct  lumiera_recmutex
 Recursive Mutex. More...
 

Functions

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.
 
LumieraRecmutex lumiera_recmutex_destroy (LumieraRecmutex self, struct nobug_flag *flag, const struct nobug_context ctx)
 Destroy a recursive mutex variable.
 
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_trylock (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 void lumiera_recmutex_unlock (LumieraRecmutex self, struct nobug_flag *flag, struct nobug_resource_user **handle, const struct nobug_context ctx)
 

Typedef Documentation

◆ LumieraRecmutex

typedef lumiera_recmutex* LumieraRecmutex

Definition at line 85 of file recmutex.h.

Macro Definition Documentation

◆ LUMIERA_RECMUTEX_SECTION

#define LUMIERA_RECMUTEX_SECTION (   nobugflag,
  mtx 
)
Value:
for (lumiera_sectionlock NOBUG_CLEANUP(lumiera_sectionlock_ensureunlocked) \
lumiera_lock_section_ = { \
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; \
}); \
({ \
}))
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:230
#define LUMIERA_RECMUTEX_SECTION_UNLOCK
Definition recmutex.h:70
void(* lumiera_sectionlock_unlock_fn)(void *, struct nobug_flag *flag, struct nobug_resource_user **handle, const struct nobug_context ctx)
Definition sectionlock.h:26
static void lumiera_sectionlock_ensureunlocked(LumieraSectionlock self)
Definition sectionlock.h:45

Recursive Mutual exclusive section.

Definition at line 32 of file recmutex.h.

◆ 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_ = { \
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; \
}); \
({ \
}))

Definition at line 49 of file recmutex.h.

◆ LUMIERA_RECMUTEX_SECTION_UNLOCK

#define LUMIERA_RECMUTEX_SECTION_UNLOCK    LUMIERA_SECTION_UNLOCK_(&lumiera_lock_section_)

Definition at line 70 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 32 of file recmutex.c.

References recmutexattr, recmutexattr_init(), and recmutexattr_once.

Referenced by lumiera_interfaceregistry_init(), and TEST().

+ Here is the call graph for this function:
+ Here is the caller graph for this function:

◆ 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 53 of file recmutex.c.

References LUMIERA_DIE.

Referenced by lumiera_interfaceregistry_destroy(), and TEST().

+ Here is the caller graph for this function:

◆ lumiera_recmutex_lock()

static LumieraRecmutex lumiera_recmutex_lock ( LumieraRecmutex  self,
struct nobug_flag *  flag,
struct nobug_resource_user **  handle,
const struct nobug_context  ctx 
)
inlinestatic

Definition at line 111 of file recmutex.h.

References LUMIERA_DIE.

◆ lumiera_recmutex_trylock()

static LumieraRecmutex lumiera_recmutex_trylock ( LumieraRecmutex  self,
struct nobug_flag *  flag,
struct nobug_resource_user **  handle,
const struct nobug_context  ctx 
)
inlinestatic

Definition at line 132 of file recmutex.h.

References lumiera_lockerror_set(), and NULL.

+ Here is the call graph for this function:

◆ lumiera_recmutex_timedlock()

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 
)
inlinestatic

Definition at line 161 of file recmutex.h.

References lumiera_lockerror_set(), and NULL.

+ Here is the call graph for this function:

◆ lumiera_recmutex_unlock()

static void lumiera_recmutex_unlock ( LumieraRecmutex  self,
struct nobug_flag *  flag,
struct nobug_resource_user **  handle,
const struct nobug_context  ctx 
)
inlinestatic

Definition at line 191 of file recmutex.h.

References LUMIERA_DIE.