Semaphors, Mutexes and Conditions. More...
#include <pthread.h>
#include <errno.h>
Go to the source code of this file.
Macros | |
#define | janus_mutex_init(a) pthread_mutex_init(a,NULL) |
Janus mutex initialization. More... | |
#define | JANUS_MUTEX_INITIALIZER PTHREAD_MUTEX_INITIALIZER |
Janus static mutex initializer. More... | |
#define | janus_mutex_destroy(a) pthread_mutex_destroy(a) |
Janus mutex destruction. More... | |
#define | janus_mutex_lock_nodebug(a) pthread_mutex_lock(a); |
Janus mutex lock without debug. More... | |
#define | janus_mutex_lock_debug(a) { printf("[%s:%s:%d:] ", __FILE__, __FUNCTION__, __LINE__); printf("LOCK %p\n", a); pthread_mutex_lock(a); }; |
Janus mutex lock with debug (prints the line that locked a mutex) More... | |
#define | janus_mutex_lock(a) { if(!lock_debug) { janus_mutex_lock_nodebug(a); } else { janus_mutex_lock_debug(a); } }; |
Janus mutex lock wrapper (selective locking debug) More... | |
#define | janus_mutex_unlock_nodebug(a) pthread_mutex_unlock(a); |
Janus mutex unlock without debug. More... | |
#define | janus_mutex_unlock_debug(a) { printf("[%s:%s:%d:] ", __FILE__, __FUNCTION__, __LINE__); printf("UNLOCK %p\n", a); pthread_mutex_unlock(a); }; |
Janus mutex unlock with debug (prints the line that unlocked a mutex) More... | |
#define | janus_mutex_unlock(a) { if(!lock_debug) { janus_mutex_unlock_nodebug(a); } else { janus_mutex_unlock_debug(a); } }; |
Janus mutex unlock wrapper (selective locking debug) More... | |
#define | janus_condition_init(a) pthread_cond_init(a,NULL) |
Janus condition initialization. More... | |
#define | janus_condition_destroy(a) pthread_cond_destroy(a) |
Janus condition destruction. More... | |
#define | janus_condition_wait(a, b) pthread_cond_wait(a, b); |
Janus condition wait. More... | |
#define | janus_condition_timedwait(a, b, c) pthread_cond_timedwait(a, b, c); |
Janus condition timed wait. More... | |
#define | janus_condition_signal(a) pthread_cond_signal(a); |
Janus condition signal. More... | |
#define | janus_condition_broadcast(a) pthread_cond_broadcast(a); |
Janus condition broadcast. More... | |
Typedefs | |
typedef pthread_mutex_t | janus_mutex |
Janus mutex implementation. More... | |
typedef pthread_cond_t | janus_condition |
Janus condition implementation. More... | |
Variables | |
int | lock_debug |
Semaphors, Mutexes and Conditions.
Implementation (based on pthread) of a locking mechanism based on mutexes and conditions.
#define janus_condition_broadcast | ( | a | ) | pthread_cond_broadcast(a); |
Janus condition broadcast.
#define janus_condition_destroy | ( | a | ) | pthread_cond_destroy(a) |
Janus condition destruction.
#define janus_condition_init | ( | a | ) | pthread_cond_init(a,NULL) |
Janus condition initialization.
#define janus_condition_signal | ( | a | ) | pthread_cond_signal(a); |
Janus condition signal.
#define janus_condition_timedwait | ( | a, | |
b, | |||
c | |||
) | pthread_cond_timedwait(a, b, c); |
Janus condition timed wait.
#define janus_condition_wait | ( | a, | |
b | |||
) | pthread_cond_wait(a, b); |
Janus condition wait.
#define janus_mutex_destroy | ( | a | ) | pthread_mutex_destroy(a) |
Janus mutex destruction.
#define janus_mutex_init | ( | a | ) | pthread_mutex_init(a,NULL) |
Janus mutex initialization.
#define JANUS_MUTEX_INITIALIZER PTHREAD_MUTEX_INITIALIZER |
Janus static mutex initializer.
#define janus_mutex_lock | ( | a | ) | { if(!lock_debug) { janus_mutex_lock_nodebug(a); } else { janus_mutex_lock_debug(a); } }; |
Janus mutex lock wrapper (selective locking debug)
#define janus_mutex_lock_debug | ( | a | ) | { printf("[%s:%s:%d:] ", __FILE__, __FUNCTION__, __LINE__); printf("LOCK %p\n", a); pthread_mutex_lock(a); }; |
Janus mutex lock with debug (prints the line that locked a mutex)
#define janus_mutex_lock_nodebug | ( | a | ) | pthread_mutex_lock(a); |
Janus mutex lock without debug.
#define janus_mutex_unlock | ( | a | ) | { if(!lock_debug) { janus_mutex_unlock_nodebug(a); } else { janus_mutex_unlock_debug(a); } }; |
Janus mutex unlock wrapper (selective locking debug)
#define janus_mutex_unlock_debug | ( | a | ) | { printf("[%s:%s:%d:] ", __FILE__, __FUNCTION__, __LINE__); printf("UNLOCK %p\n", a); pthread_mutex_unlock(a); }; |
Janus mutex unlock with debug (prints the line that unlocked a mutex)
#define janus_mutex_unlock_nodebug | ( | a | ) | pthread_mutex_unlock(a); |
Janus mutex unlock without debug.
typedef pthread_cond_t janus_condition |
Janus condition implementation.
typedef pthread_mutex_t janus_mutex |
Janus mutex implementation.
int lock_debug |