Lumiera  0.pre.03
»edityourfreedom«
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Macros Modules Pages
condition.h File Reference

Go to the source code of this file.

Description

Condition variables, header.

Definition in file condition.h.

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

Classes

struct  lumiera_condition
 Condition variables. More...
 

Typedefs

typedef lumiera_condition * LumieraCondition
 

Macros

#define LUMIERA_CONDITION_BROADCAST
 Broadcast a condition variable Must be used inside a CONDITION_SECTION. More...
 
#define LUMIERA_CONDITION_SECTION(nobugflag, cnd)
 Condition section. More...
 
#define LUMIERA_CONDITION_SECTION_CHAIN(nobugflag, cnd)
 
#define LUMIERA_CONDITION_SECTION_UNLOCK
 
#define LUMIERA_CONDITION_SIGNAL
 Signal a condition variable Must be used inside a CONDITION_SECTION. More...
 
#define LUMIERA_CONDITION_TIMEDWAIT(expr, timeout)
 Timed wait for a condition. More...
 
#define LUMIERA_CONDITION_WAIT(expr)
 Wait for a condition. More...
 

Functions

static void lumiera_condition_broadcast (LumieraCondition self, struct nobug_flag *flag, const struct nobug_context ctx)
 
LumieraCondition lumiera_condition_destroy (LumieraCondition self, struct nobug_flag *flag, const struct nobug_context ctx)
 Destroy a condition variable. More...
 
LumieraCondition lumiera_condition_init (LumieraCondition self, const char *purpose, struct nobug_flag *flag, const struct nobug_context ctx)
 Initialise a condition variable. More...
 
static LumieraCondition lumiera_condition_lock (LumieraCondition self, struct nobug_flag *flag, struct nobug_resource_user **handle, const struct nobug_context ctx)
 
static void lumiera_condition_signal (LumieraCondition self, struct nobug_flag *flag, const struct nobug_context ctx)
 
static LumieraCondition lumiera_condition_timedlock (LumieraCondition self, const struct timespec *timeout, struct nobug_flag *flag, struct nobug_resource_user **handle, const struct nobug_context ctx)
 
static LumieraCondition lumiera_condition_timedwait (LumieraCondition self, const struct timespec *timeout, struct nobug_flag *flag, struct nobug_resource_user **handle, const struct nobug_context ctx)
 
static LumieraCondition lumiera_condition_trylock (LumieraCondition self, struct nobug_flag *flag, struct nobug_resource_user **handle, const struct nobug_context ctx)
 
static void lumiera_condition_unlock (LumieraCondition self, struct nobug_flag *flag, struct nobug_resource_user **handle, const struct nobug_context ctx)
 
static LumieraCondition lumiera_condition_wait (LumieraCondition self, struct nobug_flag *flag, struct nobug_resource_user **handle, const struct nobug_context ctx)
 

Typedef Documentation

typedef lumiera_condition* LumieraCondition

Definition at line 163 of file condition.h.

Macro Definition Documentation

#define LUMIERA_CONDITION_SECTION (   nobugflag,
  cnd 
)

Condition section.

Locks the condition mutex, one can use LUMIERA_CONDITION_WAIT to wait for signals or LUMIERA_CONDITION_SIGNAL or LUMIERA_CONDITION_BROADCAST to wake waiting threads Condition variables must be at the end of locking chains, they can not be used at intermediate position.

Parameters
nobugflagNoBug flag used to log actions on the condition
cndCondition variable to be locked

Definition at line 49 of file condition.h.

#define LUMIERA_CONDITION_SECTION_CHAIN (   nobugflag,
  cnd 
)

Definition at line 66 of file condition.h.

#define LUMIERA_CONDITION_SECTION_UNLOCK

Definition at line 87 of file condition.h.

#define LUMIERA_CONDITION_WAIT (   expr)

Wait for a condition.

Must be used inside a CONDITION_SECTION.

Parameters
exprConditon which must become true, else the condition variable goes back into sleep

Definition at line 96 of file condition.h.

Referenced by LUMIERA_CONDITION_SECTION(), lumiera_thread_join(), lumiera_thread_sync_other(), lumiera_threadpool_acquire_thread(), lumiera_threadpool_destroy(), TEST(), thread_loop(), and threadsyncfn().

#define LUMIERA_CONDITION_TIMEDWAIT (   expr,
  timeout 
)

Timed wait for a condition.

Must be used inside a CONDITION_SECTION.

Parameters
exprConditon which must become true, else the condition variable goes back into sleep
timeouttime when the wait expired sets LUMIERA_ERROR_LOCK_TIMEOUT when the timeout passed

Definition at line 113 of file condition.h.

#define LUMIERA_CONDITION_SIGNAL

Signal a condition variable Must be used inside a CONDITION_SECTION.

Wakes one thread waiting on the condition variable

Definition at line 129 of file condition.h.

Referenced by LUMIERA_CONDITION_SECTION(), lumiera_thread_destroy(), lumiera_thread_join(), lumiera_thread_run(), lumiera_thread_sync_other(), TEST(), thread_loop(), and threadsyncfn().

#define LUMIERA_CONDITION_BROADCAST

Broadcast a condition variable Must be used inside a CONDITION_SECTION.

Wakes all threads waiting on the condition variable

Definition at line 143 of file condition.h.

Referenced by LUMIERA_CONDITION_SECTION(), and lumiera_threadpool_release_thread().

Function Documentation

LumieraCondition lumiera_condition_init ( LumieraCondition  self,
const char *  purpose,
struct nobug_flag *  flag,
const struct nobug_context  ctx 
)

Initialise a condition variable.

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

Definition at line 31 of file condition.c.

References NULL.

Referenced by lumiera_thread_new(), lumiera_threadpool_init(), and TEST().

+ Here is the caller graph for this function:

LumieraCondition lumiera_condition_destroy ( LumieraCondition  self,
struct nobug_flag *  flag,
const struct nobug_context  ctx 
)

Destroy a condition variable.

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

Definition at line 50 of file condition.c.

References LUMIERA_DIE.

Referenced by lumiera_thread_destroy(), lumiera_threadpool_destroy(), and TEST().

+ Here is the caller graph for this function:

static LumieraCondition lumiera_condition_lock ( LumieraCondition  self,
struct nobug_flag *  flag,
struct nobug_resource_user **  handle,
const struct nobug_context  ctx 
)
inlinestatic

Definition at line 190 of file condition.h.

References LUMIERA_DIE.

static LumieraCondition lumiera_condition_trylock ( LumieraCondition  self,
struct nobug_flag *  flag,
struct nobug_resource_user **  handle,
const struct nobug_context  ctx 
)
inlinestatic

Definition at line 211 of file condition.h.

References lumiera_lockerror_set(), and NULL.

+ Here is the call graph for this function:

static LumieraCondition lumiera_condition_timedlock ( LumieraCondition  self,
const struct timespec *  timeout,
struct nobug_flag *  flag,
struct nobug_resource_user **  handle,
const struct nobug_context  ctx 
)
inlinestatic

Definition at line 240 of file condition.h.

References lumiera_lockerror_set(), and NULL.

+ Here is the call graph for this function:

static LumieraCondition lumiera_condition_wait ( LumieraCondition  self,
struct nobug_flag *  flag,
struct nobug_resource_user **  handle,
const struct nobug_context  ctx 
)
inlinestatic

Definition at line 270 of file condition.h.

Referenced by lumiera_thread_sync().

+ Here is the caller graph for this function:

static LumieraCondition lumiera_condition_timedwait ( LumieraCondition  self,
const struct timespec *  timeout,
struct nobug_flag *  flag,
struct nobug_resource_user **  handle,
const struct nobug_context  ctx 
)
inlinestatic

Definition at line 289 of file condition.h.

References lumiera_lockerror_set(), and NULL.

+ Here is the call graph for this function:

static void lumiera_condition_signal ( LumieraCondition  self,
struct nobug_flag *  flag,
const struct nobug_context  ctx 
)
inlinestatic

Definition at line 320 of file condition.h.

Referenced by lumiera_thread_sync().

+ Here is the caller graph for this function:

static void lumiera_condition_broadcast ( LumieraCondition  self,
struct nobug_flag *  flag,
const struct nobug_context  ctx 
)
inlinestatic

Definition at line 330 of file condition.h.

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

Definition at line 340 of file condition.h.

References LUMIERA_DIE.